I am unable to run rails g or rails c, because of the following error message:
Could not find mysql2-0.3.18 in any of the sources
Run `bundle install` to install missing gems.
I can run 'rails server', which works fine, as expected. I also have ran bundle install, with no errors (this line is in my Gemfile: gem 'mysql2'). The database works fine with rails server, but seems to break with rails g/c.
Update:
I can run rails g and rails c with sudo. I think it's a problem with my path - I think I might have installed MySQL as root.
Have you tried running those commands using Bundler?
bundle exec rails c
bundle exec rails g
Related
My rails development environment runs in Docker, and I cannot start the rails console without disabling spring using DISABLE_SPRING=true. The snipper below illustrates what happens:
app#docker:[project] $ bundle exec rails c
Could not find rake-13.0.6 in any of the sources
Run `bundle install` to install missing gems.
app#docker:[project] $ DISABLE_SPRING=true bundle exec rails c
D, [2022-01-19T03:44:17.663136 #20] DEBUG -- sentry: initialized a background worker with 6 threads
Loading development environment (Rails 6.1.4.4)
irb(main):001:0>
I've tried rebuilding my docker image from scratch, deleting the Gemfile.lock and building again. Nothing works, except for disabling spring.
Surprisingly, rails server works fine.
Any ideas?
I have deployed a rails application using capistrano on a linux server and it is running without any problems. When I connect to my remote server via ssh, the folder structure of my app is quite different from what I have on my local machine. I would like to go to project root and say rails console so that I can have access to the console of my application. Is there a way to achieve this?
When I go to ~MyApp/ folder and run rails console it says command rails not found. I think that is probably because the app is running in another folder.
bundle exec to the rescue inside of project folded:
$ RAILS_ENV=production bundle exec rails console
If you've installed with rbenv it could be that you are defaulting to the wrong Ruby version. So you can run rbenv exec to get it to run on the right version, along with bundle exec to run the right version of Rails
So try running this:
rbenv exec bundle exec rails console
To sum up for anyone having the same problem in the future,
I went to MyApp/releases/2020331231231231 which is the latest release of my app and there I used this command RAILS_ENV=production bundle exec rails console and I was able to do whatever I wanted to do in the console.
First you need to move inside the folder where the code is.
Check Capistrano config if deploy_to is defined. (If it's not it should be set to /var/www/#{application}/ by default read here)
Since Capistrano keep older versions of your app go to the current folder which is a symlink of the latest deployed version.
And run ENVIRONMENT=production bundle exec rails c or ENVIRONMENT=production bin/rails c. If doesn't work try with rbenv ENVIRONMENT=production rbenv exec bundle exec rails c
Rails C and Rails S not working when in the correct directory.
have tried:
$ bundle exec rake rails:update:bin
this returns the following error:
bundler: command not found: rails:update:bin
Install missing gem executables with `bundle install`
I have ran:
Bundle Install
this still returns the same error
Have changed directories (higher and lower), repeated steps and attempted commends for same result.
I was running rails server, when i stopped the server and tried to restart server, the error appeared, so I'm thinking this has something to do with a physical location change (potentially the bin file), which is consistent as when I try and run a bin/rails command, i'm receiving an error of:
bundler: command not found: rails:update:bin
Install missing gem executables with `bundle install`
I have tried to rake the bin folder as below:
rake rails:update:bin
however I am receiving this error:
rake aborted!
Don't know how to build task 'rails:update:bin' (see --tasks)
Finally, I have checked the physical location and there is a .bin file, however this folder is empty and it's not in a .gitignore directory.
Ancillary information
Rails version: 5.1.4
ruby version: 2.3.4
Server: heroku
OS. Ubuntu 16.04 (via virtualbox).
I have not upgraded rails, this is a fresh install
I am at a loss.
rails update:bin or rake update:bin These are the right ways that execute a rake task.
This link is great.
However, there is a problem that I am having that I can not figure out. There are gems that I set in my Gemfile that rails seems not to recognize.
When I navigate to my rails application and run these two commands they give me unexpected results.
bundle exec irb
$:
and
bundle exec rails c
$:
gives different result. The former give more paths (which include paths to gems), and the later less. I thought it should be the other way around.
And specifically the bundle exec irb loads all the gems from the my Gemfile. But bundle exec rails c only loads some of the gems from the Gemfile.
How do I get rails to load all my gems from the Gemfile of my rails application?
I am in process of installing Redmine app via RedmineInstall documentation I try step 5 :
bundle exec rake db:migrate
then error shows :
bundler: command not found: rake
Install missing gem executables with ´bundle install´
I use redmine 3.3.0 64 for windows
I use redmine gemfile and rake was installed (i see Using rake 11.2.2)
I tried reinstall it via bundle install or gem install/uninstall, but did not help (see Successfully installed rake-11.2.2 but rake do not work).
I tried this command from ruby/bin directory or redmine directory not success.
I do not understand, that rake is successfully installed, but when i try use it with bundle it says that command not found.
The problem may be in the directory where the Redmine or rake?
Try rake db:migrate in your redmine directory without bundle exec and see if that resolves your issue.
Bundler usually provides bin stubs for rake and other gem files, so that bundle exec is not necessary or will even fail because it will look in an other gem directory where, in this case, rake might not be installed.