• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Tilde(~) in Path Breaks CI4 (used in iCloud Drive Path)

#1
CI4 breaks when it encounters a path that has a tilde(~) in it.
Unfortunately, Apple uses tildes in its iCloud Drive path name, which is rendered as:
Code:
/Users/username/Library/Mobile Documents/com~apple~CloudDocs


When using PHP's built-in web server on MacOS:
Code:
cd  /Users/moo/Library/Mobile Documents/com~apple~CloudDocs/Sites/ci4b1/
php -S localhost:8892 -t $(pwd)/public
... the user-visible path
Code:
/Users/myname/Sites/ci4b1/
...ACTUALLY resolves to
Code:
/Users/myname/Library/Mobile Documents/com~apple~CloudDocs/Sites/ci4b1/
Returning this response:
Code:
Fatal error: Uncaught Error: Class 'Config\App' not found in /Users/myname/Library/Mobile Documents/com~apple~CloudDocs/Sites/ci4b1/vendor/codeigniter4/framework/system/Config/Config.php on line 139

The same fatal error returns when executing spark at the CLI if the CI4 folder is located in a path containing a tilde(~) .

Code:
➜  ci4b1 pwd
/Users/moo/Desktop/folder_with_a_tilde~/ci4b1
➜  ci4b1 ./spark
PHP Fatal error:  Uncaught Error: Class 'Config\App' not found in /Users/moo/Desktop/folder_with_a_tilde~/ci4b1/vendor/codeigniter4/framework/system/Config/Config.php:139
Stack trace:
#0 /Users/moo/Desktop/folder_with_a_tilde~/ci4b1/vendor/codeigniter4/framework/system/Config/Config.php(80): CodeIgniter\Config\Config::createClass('Config\\App')
#1 /Users/moo/Desktop/folder_with_a_tilde~/ci4b1/vendor/codeigniter4/framework/system/Common.php(99): CodeIgniter\Config\Config::get('Config\\App', true)
#2 /Users/moo/Desktop/folder_with_a_tilde~/ci4b1/vendor/codeigniter4/framework/system/bootstrap.php(158): config('Config\\App')
#3 /Users/moo/Desktop/folder_with_a_tilde~/ci4b1/spark(44): require('/Users/moo/Desk...')
#4 {main}
 thrown in /Users/moo/Desktop/folder_with_a_tilde~/ci4b1/vendor/codeigniter4/framework/system/Config/Config.php on line 139

Fatal error: Uncaught Error: Class 'Config\App' not found in /Users/moo/Desktop/folder_with_a_tilde~/ci4b1/vendor/codeigniter4/framework/system/Config/Config.php:139
Stack trace:
#0 /Users/moo/Desktop/folder_with_a_tilde~/ci4b1/vendor/codeigniter4/framework/system/Config/Config.php(80): CodeIgniter\Config\Config::createClass('Config\\App')
#1 /Users/moo/Desktop/folder_with_a_tilde~/ci4b1/vendor/codeigniter4/framework/system/Common.php(99): CodeIgniter\Config\Config::get('Config\\App', true)
#2 /Users/moo/Desktop/folder_with_a_tilde~/ci4b1/vendor/codeigniter4/framework/system/bootstrap.php(158): config('Config\\App')
#3 /Users/moo/Desktop/folder_with_a_tilde~/ci4b1/spark(44): require('/Users/moo/Desk...')
#4 {main}
 thrown in /Users/moo/Desktop/folder_with_a_tilde~/ci4b1/vendor/codeigniter4/framework/system/Config/Config.php on line 139
➜  ci4b1
Reply

#2
Does anyone have an idea of how we can work around this?

The error occurs in the final line of
/Users/moo/Desktop/folder_with_a_tilde~/ci4b1/vendor/codeigniter4/framework/system/Config/Config.php
in createClass where we are creating a new class instance using the name that was passed in.

vendor/codeigniter4/framework/system/Config/Config::createClass(string $name):
Code:
    /**
     * Find configuration class and create instance
     *
     * @param string $name Classname
     *
     * @return mixed|null
     */
    private static function createClass(string $name)
    {

       if (class_exists($name))
        {
            return new $name();
        }

        $locator = Services::locator();

       $file    = $locator->locateFile($name, 'Config');

        if (empty($file))
        {
            return null;
        }

        $name = $locator->getClassname($file);

        if (empty($name))
        {
            return null;
        }
               CODE DIES HERE:
        return new $name();
    }
Reply

#3
From what I have read it's a short cut for you home folder.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply

#4
(03-05-2019, 05:27 AM)InsiteFX Wrote: From what I have read it's a short cut for you home folder.

Yes, it is the actual path to the mount points for MacOS iCloud Drive/ and iOS "Files" app.

Since that remote storage mechanism is so useful for developers using MacOS,
I'm trying to figure out how to get CodeIgniter 4 working there.
Reply

#5
Anyone have an idea for a workaround?
Reply

#6
If you can get the path to the short cut then you should be able to just enter that
as the url link.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply

#7
(03-07-2019, 05:16 AM)InsiteFX Wrote: If you can get the path to the short cut then you should be able to just enter that
as the url link.

Read my post and you'll see that I've done that.
Reply

#8
Can you use a route for this, so that the tilde is not in the URL?
Reply

#9
Well, the obvious answer is don't store it in the iCloud drive Smile

Here's a workaround to expand the filenames, though I'm not sure how many different places would need to use that. I'm also unconvinced it's a good thing to have in core as it feels like it could be a security issue, though I'd have to think for a bit on when it could be safe and when not.
Support Development  • Practical CodeIgniter 3  • Vulcan - CLI Tools for CI4
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.