13

I have installed a Laravel app locally using the Laravel Installer. Now I want to upload the app to my production server which is a managed virtual server, but it fulfills all the needed requirements.

I have uploaded the app and changed in the .env file the APP_URL and the DB_* settings accordingly. When I login to my server via ssh, go inside the app folder and try to use tinker

php artisan tinker

I get the following error message:

enter image description here

The error message makes sense, because the wp10*** folder does not contain a .config folder. However, I do not have permission to create folders at the same level as the www folder. Is it possible to put the folder inside the Laracast project folder? In my example this would be /is/htdocs/wp_10**/www/laracast/p1/.config/psysh. If so, how do I tell Laravel the new location?

Adam
  • 25,960
  • 22
  • 158
  • 247

8 Answers8

20

If you can't give access to use the default directory,

You can change the directory path in .env file:

XDG_CONFIG_HOME=/home/some/directory

Thanks to bernhardh

Amin Shojaei
  • 5,451
  • 2
  • 38
  • 46
17

Tinker is trying to create the .config folder, and it's not per-app configuration, it's stored against the user.

I don't think you can change the directory path, but creating the directory and setting permissions on it will allow you to use tinker.

mkdir -p ~/.config/psysh chmod -R 755 ~/.config

It is worth double checking the user permissions before you try this, as you should always be able to write directly to your users home directory.

jrdn
  • 819
  • 2
  • 10
  • 21
3

Or you can use :

sudo chmod -R 755 ~/.config

then make directory:

mkdir -p ~/.config/psysh

and :

php artisan tinker.

Mahsa Sirous
  • 75
  • 1
  • 6
1

Verify that .config and psysh belong to your user, try changing the owner with chown and set the permissions to 700

1

I had the same issue on a Laravel 9 app running in a non-root Docker container.

I fixed it by creating the matching user inside of the container so that it gets a home directory. Then, Psysh was able to write its config in the user's home.

With that setup, no need to change any XDG_CONFIG_HOME or PSYSH_CONFIG vars.

Moreover, using those XDG_CONFIG_HOME or PSYSH_CONFIG env vars is irrelevant if you use Laravel config caching.

Franck
  • 560
  • 7
  • 20
  • This is exactly the solution I'm looking for. Could you elaborate on it ? You created a user in your docker-compose file ? I have a user: 1000:1000 in both my containers, yet I still get that issue. – ayame Sep 10 '22 at 03:20
  • If you run your container as user 1000 with `user: "1000:1000"` in your Compose file, you need to have a real user with ID `1000` in your container. That means your Docker image needs to have this user created before runtime. And that shall be done in your image `Dockerfile` with `RUN adduser johndoe --uid 1000`. Then pull your image, rebuild your container and you're done. – Franck Sep 11 '22 at 16:36
  • THANK YOU! This worked for me. Crazy how a sub-comment is better than the actual solutions posted. – ayame Sep 14 '22 at 02:31
0

Try this

sudo chmod -R 777 ~/.config

If Directory is not exists

mkdir -p ~/.config/psysh

Then check again

php artisan tinker
bhavinjr
  • 1,663
  • 13
  • 19
0

if working with Laragon on windows you can try go to c drive then click on the user folder you are using then right click and then properties go to security and then click edit(all/everyone). Then check all the boxes so you are permitted to write to the file.how it looks here

-2

Fixed! For Windows, run your terminal or app as an administrator.