I need to go to “Rails console”
$ flyctl ssh console -C “/bin/app/rails console”
show:
Connecting to top1.nearest.of.*****.internal… complete
fork/exec /bin/app/rails: no such file or directory
please help me thanks
I need to go to “Rails console”
$ flyctl ssh console -C “/bin/app/rails console”
show:
Connecting to top1.nearest.of.*****.internal… complete
fork/exec /bin/app/rails: no such file or directory
please help me thanks
Did you use fly launch
to create the Rails app? If so I think that path is a bit off; See this doc:
I think path would be more like app/bin/rails <subcommand>
I don’t know your app path, maybe /app/bin/rails console
?
Maybe this path needs to be changed?
Path problem has been solved
but a new situation
Connecting to top1.nearest.of.*****.internal... complete
fork/exec /app/bin/rails: permission denied
please help thank you
I usually use flyctl ssh console
to connect ssh then execute the command.
Use whoami
to check username and ls -l /app/bin/rails
to check execute file permission.
$ flyctl ssh console
Connecting to top1.nearest.of.*****.internal... complete
# ls -l /app/bin/rails
-rw-r--r-- 1 1001 121 145 Sep 1 15:03 /app/bin/rails
# whoami
root
@chloerei How to change permissions?
please help thank you
Not familiar with the rails Dockerfile, but a workaround could be adding this line to it
RUN chmod 755 /app/bin/rails
bin/rails
script need execute permission, use
chmod +x /app/bin/rails
to add execute permision.
If it works, run chmod +x bin/rails
in your local project directory and commit to permanently fix this issue.
Scripts in bin
directory all have execute permission by default.
@chloerei @tj1 @jphenow
thank you for the help
I have successfully opened permissions
But I encountered a new situation
An error occurred:
/usr/bin/env: 'ruby.exe': No such file or directory
if I delete the following paragraph
bin\rails :
#!/usr/bin/env ruby.exe
An error occurred:
fork/exec /app/bin/rails: exec format error
please help thank you
Change to:
#!/usr/bin/env ruby
Are you develop on windows? Differences between development and production environments can cause many problems. I recommend use WSL2 or Docker to run a linux environment.
@chloerei i use windows OS
Loading production environment (Rails 6.1.6.1)
irb(main):001:0>
amazing!
You are amazing!!
Thanks for your help!!!
@jedi - glad you are up and running! I’ve fixed the docs.
The changes you made will be undone the next time you deploy. Try adding the following to your Dockerfile so that the changes will be applied for you automatically each time you deploy:
sed -i 's/ruby.exe/ruby/' app/bin/*
chmod +x app/bin/*
Place these lines immediately after the COPY . .
line. I’ll modify flyctl to do this automatically going forward, and that will change will be available within a few days.
Oops! Sorry about that. Add the word RUN before each of those lines:
RUN sed -i 's/ruby.exe/ruby/' app/bin/*
RUN chmod +x app/bin/*
Eek! Need more coffee. Since this is after the WORKDIR
line earlier in the Dockerfile
, the file names need to be either relative to the WORKDIR
or be absolute. Let’s make them absolute:
RUN sed -i 's/ruby.exe/ruby/' /app/bin/*
RUN chmod +x /app/bin/*
Set up successfully !! thank you
But I’m having trouble again…
The following cannot be used :
flyctl ssh console -c "/app/bin/rails db:migrate"
flyctl ssh console -c "/app/bin/rails db:rollback"
The following can be used :
flyctl ssh console -C "/app/bin/rails console"
flyctl ssh console -C "/app/bin/rails help"
please help thank you
The option needs to be an uppercase -C
.
Adding another line to your Dockerfile
may help. I’ve cleaned it up and tested it this time:
RUN chmod +x /app/bin/* && \
sed -i 's/ruby.exe/ruby/' /app/bin/* && \
sed -i '/^#!/aDir.chdir File.expand_path("..", __dir__)' /app/bin/*
Hope this gets you up an running! If you continue to have problems, can you paste the contents of your bin/rails
file?
I noticed this error in the guide as well, I made a PR:
you are an amazing magician
According to your parameter changes, all commands can be successfully executed! !
Thank you very much for your assistance!
Content you need: (bin\rails)
#!/usr/bin/env ruby.exe
APP_PATH = File.expand_path('../config/application', __dir__)
require_relative "../config/boot"
require "rails/commands"