Unable to start db in saas template because of permission error in WSL
Whenever I do
wasp new
I can successfully create a new app and start the db successfully (when it defaults to sql) but when I do the saas template and it defaults to postgres, I have tried many ways to fix this and I still get this error:
wasp-bin: /home/alex/wasptest/app/main.wasp: openFile: permission denied (Permission denied)I was at first getting this error below. I then enabled sockets per the docs instructions, and the error message changed to the above, regarding the openFile command.
wasp-bin: Network.Socket.bind: permission denied (Permission denied)I am using WSL, if that matters. I receive this error when I run the commands in order of the docs instructions. I tried this with and without pgadmin running, and I also tried this with and without a db url in my env file. I am unsure what else to try, or if I need to give permissions to wasp in my WSL CLI. any suggestions?
24 Replies
Hi @alex. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Based on the knowledge sources provided, it seems like you're encountering permission issues when trying to start your PostgreSQL database with Wasp. This could be due to your Docker setup or the permissions set in your WSL environment.
Here are a few suggestions based on the information from the knowledge sources:
1. Ensure Docker is properly set up and integrated with your WSL environment. You can check this by running
docker run --help
from your WSL terminal. If Docker is not properly set up, you might need to enable WSL integration in your Docker Desktop settings.
2. Try running the Docker command that Wasp was trying to run. You can find this command in the error message you received. It should look something like this:
Replace yourAppName
with the name of your Wasp app.
3. If you're still encountering permission issues, you might need to adjust the permissions of your Docker daemon socket. One of the community members in the knowledge sources suggested the following steps:
- Open a terminal and enter sudo chmod 666 /var/run/docker.sock
- Restart the Docker Desktop on Windows to apply the changes.
After completing these steps, try running your Docker command again.
If you're still encountering issues, it might be helpful to seek further assistance from the Wasp community or check the Wasp documentation for more information.
Sources:
- Discord support thread: Cant start database docker is not working on wsl properly (https://discord.com/channels/686873244791210014/1194876839911510046)
- Discord support thread: [SOLVED] OpenSaaS installation docker and db issue (https://discord.com/channels/686873244791210014/1193138068195119104)
- Discord support thread: Unable to run "wasp start db" in my terminal (https://discord.com/channels/686873244791210014/1212373984453075004)
- Discord support thread: Need help running Wasp app (https://discord.com/channels/686873244791210014/1215223623271321661)
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @alex, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist:
Perhaps try again in 15mins?Update: Realized docker daemon is not running, and this is likely this issue. doing some things to get this working with WSL. will post step by step if i get this working
I tried everything, and converted my WSL instance to WSL2 and made sure the docker daemon was running -- still unable to
wasp start
or wasp db start
@alex yes this will be specific to WSL!
We do have peoploe running Wasp on WSL so it should certainly work, but what specifically is problem with your setup I am not sure hm.
So,
wasp start
fails with the error taht it can't connect to the database, right? What exactly is that error?
When you try wasp db start
, what happens then? What error exactly do you get?
NOTE: If you already have postgres running in the background, wasp db start
won't be able to start because postgres
is already likely occyupying port 5432. In that, you can turn off postgres, or you can choose to connect to it directly and use that instead of wasp db start
, but then you need to configure env var in .env.server for connecting to the DB. Docs should cover this quite nicely I believethank you for the reply! Yes I have closed postgres to be sure so that is not the problem. I actually changed my provider to sqlite just to see if the issue was postgres, but it still gave the same error.
when I run
wasp start
or wasp db start
I receive this error
wasp-bin: /home/alex/wasptest/app/main.wasp: openFile: permission denied (Permission denied)this only happens when I configure with saas template and I am performing this within the app folder. When I do a basic setup and do not do the template, and I am running this command from the root folder for the project, the command runs successfully so the issue is something with the saas template, it appears that is the weird tihng. so it does not seem like it is a problem with my configuration, because this only happens within the saas template. I did a lot to ensure my docker was configured properly and had proper communication with WSL, and everything looks good. and I upgraded from WSL1 to WSL2, but the problem remains
Hmmm, so I doubt saas template can be the cause by itself, it is more likely to be somethign about how you set up saas template on your machine vs how you set up the more simpler Wasp project.
openFile ... sounds like a permissions problem! First thing that comes to my mind is that maybe you installed
wasp
with sudo
, or that there is some permissions issue with WSL file system. But you say it works with simple projects which is weird hm.
Some things to check:
1. Did you install wasp
with sudo
? If so, that could be the issue?
2. If you are using WSL2, make sure that your Wasp project is not on the Windows file system, but instead on the Linux file system. Otherwise, Wasp won't be able to detect file changes, due to the issue in WSL2.
3. Was there any difference in how you initialized your opensaas project vs a simple project? I guess you used wasp new
for both, just picked different stuff in the wizard?well everything works okay when I do the simple setup (I am able to use postgres and sql successfully) so I am not sure if it's a wasp install issue. I did not do sudo when installing wasp. it's weird because if there was a permissions issue, you would think it would show up in the simple install as well.
my wasp is definitely in my WSL file system, i don't even think windows would let me install it at all. but I did check, and it's in the proper place (simple wasp setup works so I know this is true).
And the way I did the saas template was with
wasp new -t saas
from the github repo instructions. if there is another way to do the template, I didn't see it anywhere. I can try another way if you'd like me to.Wohooo @alex, you just became a Waspeteer level 1!
Okay, I have better info
I am able to
nano main.wasp
in my simple configuration and read the file successfully
When I am within the app folder of the saas configuration, I can nano package.json
and read this successfull,y but when I do this for main.wasp, I do not have permission to open the file
something about the way the saas template is created does not properly assign permission, for some weird reason. but the simple template does this properly. or at least that's what it seems like could be the problemsudo nano main.wasp ?
ls -l
to check the permissionsI was able to sudo into it
and
sudo chmod 777 wasp.main fixed hte problem
I just made a new project with saas template and I was going to chmod the file again but I didn't have to. it worked succcessfully with no permission issues this time. that is so weird. I did it 3 times before and all of them did not work
well are you currently sudo as you are creating the new project? That might be the issue if you create it with sudo the folders will probably give permissons to the sudo only not your user
Wohooo @fustuk., you just became a Waspeteer level 5!
Hmm, I am not very familiar with linux so I do not know if sudo stays active after I use it for the 1 command. I will restart my WSL instance to clear it for sure and make another and test
type
whoami
to checkoh okay, wasn't aware of that. thank you
if you just ran a command with sudo in front you are not sudo dont worry, if you need to be type
sudo su
gotcha. yeah I restarted my WSL instance and made a new app and was not su for sure this time and there are no permission issues
I am not sure how that happened but that was hours of frustration. I guess there is no issue, it was maybe some weird error with my WSL I guess
alright, if you ever have such issues first check the file permissions then try to give yourself permissions or just using sudo
I have 1 question
Wohooo @alex, you just became a Waspeteer level 2!
and also this is related to an error that is not a wasp issue but just a WSL thing that I will put in this thread in case anyone searches for it
when I do
wasp start db
I get this error
docker: Cannot connect to the Docker daemon at tcp://0.0.0.0:2375. Is the docker daemon running?.After a lot of trial and error, I found the command that I put in to fix this
unset DOCKER_HOST
solved this issue. but my question is, where should I put this so that it is permanent? .bashrc did not seem to do the trick. any suggestions?did you comment the line in
.bashrc
?
If it didnt work I found this (common issue on wsl2 I guess)
Buy ofc run at your own risk 🙂
Thread: https://stackoverflow.com/questions/64710480/docker-client-under-wsl2-doesnt-work-without-sudoStack Overflow
Docker client under WSL2 doesn't work without sudo
On WSL2 (Ubuntu 20.04), I'm trying to connect to the Docker daemon that's running on Windows.
$ docker ps
Cannot connect to the Docker daemon at tcp://localhost:2375. Is the docker daemon running?
...
Nice job on figuring this out, and thanks @fustuk. for helping out!
My guess would be that you ran
sudo
somehwere in the wrong moment, but it is hard to say now. But as long as you got it working repeatedly, great. In general, you should try to not use sudo
if possible, although sometimes you will need to (e.g. docker setup above might require it). You certainly shouldn't have to run any wasp
commands with sudo
.
As for Docker - you are getting that error message on wasp db start
becase wasp db start
needs you to have docker installed and running in the background! So unsetting DOCKER_HOST won't solve it, you need to get docker set up and working.
Btw here is blog post on Wasp + WSL, a bit old maybe but might be useful: https://wasp-lang.dev/blog/2023/11/21/guide-windows-development-wasp-wsl