Rails Server Won't Start - ruby-on-rails

I'm trying to start my rails server with "rails server". I am getting the following error.
Could not find rake-0.9.2.2 in any of the sources
Run bundle install to install missing gems.
when I use gems, it say it is updated. Am I missing some type of path?
I am using MAC OSX Lion with the newest version of Ruby, Rake, Rails.

Run bundle install to make sure all the bundled gems are installed and available to the project.
Then try starting the server with bundle exec rails server - it's possible you've got the rake gem installed at the system level at a slightly different version level than what rails want. If you run rails via bundle exec, it'll set everything up for you

Related

Ruby on rails error Could not find rake-13.0.3 in any of the sources

What is happening with rails? A couple of days ago I everything was running smoothly and now trying to spin up the server I'm getting this error
Could not find rake-13.0.3 in any of the sources
Run `bundle install` to install missing gems.
running bundle install will create a massive cache folder under vendor and I'm able to spin up the server. However, deleting this cache folder everything breaks again. I'm running rails 6.0 and ruby 2.6.1.
I had this error when I had Ruby installed via rbenv, but rails via apt-get.
Installing rails with 'gem install' instead of 'apt' made it work for me.

Impossible to execute rails s | railties-5.2.3/exe/rails (LoadError)

I can't launch my server with the command rails s, I have to use the command bundle exec rails s, but I prefer use the command rails s
Error when I launch the command rails s
Traceback (most recent call last):
1: from /home/leopaul/.rbenv/versions/2.5.1/bin/rails:23:in `<main>'
/home/leopaul/.rbenv/versions/2.5.1/bin/rails:23:in `load': cannot load such file -- /home/leopaul/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/railties-5.2.3/exe/rails (LoadError)
My rails version is :
Rails 5.1.6.2
I think you have multiple Rails versions installed in your machine.
Sometimes when you install a gem it comes with an executable/binary as well. Examples of these include: rails, rake, rspec, pry, etc. However, when you have multiple versions of a gem installed you then will have multiple versions of these executables sitting around. So if you want to execute one of these binaries for a given rails app you may need to disambiguate which executable you want -- the one for rake v10.1 or the one for rake v10.2, for example.
So for most commands you'll want to run bundle exec to make sure you're running the right version for your project (and also to make sure that all dependencies are also loaded from the correct versions specified in your Gemfile.lock).
So answering to your question if you are able to do bundle exec rails s and unable to do rails s try reinstalling rails gem to your local machine.
gem install rails
then check current version by rails -v
I would just like to add that in my case rubygems wasn't installed.
Running sudo apt-get install rubygems solved the issue!
See docs: http://railsapps.github.io/updating-rails.html
It seems that you have installed globally is rails 4 or some other rails version and it's the reason "it doesn't execute rails s" like you say because it consider default(global rails version) rails. When you run bundle exec then it uses the rails commands from the current Gemfile, since you have rails 5 in your Gemfile then it works properly.
Also try to create gemsets for every project.
In case your case, try this:
bundle update
then excecute
rails s
Hope it will work :)

'rails c' doesn't work, but 'bundle exec rails console' does

I'm setting up the staging and production server on Ubuntu, deploy with Capistrano. Both server has pretty much the same setup. But for for some reason. I can access console on production server with rails c produciton. But when I try to access console on staging server using rails c staging
The program 'rails' can be found in the following packages:
* ruby-railties-3.2
* ruby-railties-4.0
Try: sudo apt-get install <selected package>
The only way to access console on my staging server is to do
bundle exec rails console staging
On staging
the rvm seems to be correct, I can see the ruby version I'm using.
the gemset that the application use is there.
the application is running fine. Just can't access console with 'rails c'
But for some reason, I can't access console with rails c. Any idea how to solve this issue?
I guess you didn't install rails globally. First, check your rails version you are currently using by bundle exec rails -v. Then, install rails globally by gem install rails -v <version>. This should solve your issue.
Run bundle install only makes rails available inside bundler. In most cases, this should be enough, because bundler helps prevent headaches of version conflicts.
A couple of questions to understand better the situation...
Have you tried running bundle install for the current ruby version set on rvm for that application on that server?
Have you updated the gems for another application/branch? sometimes that happens because the rails c command uses the latest gems available and bundle exec... locates and uses the gems tied to the Gemfile.lock.
The application should run fine because it uses the gems that the Gemfile.lock has listed.

Rake, bundle, rails command not found on rvm

I just installed rvm + rails 3+ on centos 6.0 at Rackspace cloud server. Everything works fine, but sometimes when i ssh to server i can't use rake, bundle or any other rails related commands it always shows me errors like:
bash: rake: command not found
when i try to run bundle install it shows me this error:
ERROR: Gem bundler is not installed, run `gem install bundler` first.
but i do have it installed for sure and it worked before.I can use rvm rake db:migrate - but it used to without rvm prefix...Please help i dont know why is that happening - maybe something wrong with bash profile...
have you used a ruby ?
rvm use 1.9.3
this will select properly environment and make all commands working properly.
to make this setting permanent for new sessions also use:
rvm use 1.9.3 --default

Unable to start Rails server

The issue is when I try to start server with rails server command after successfully created Rails app by running rails new myapp -d=mysql. However, I cant get the server to start and it gives me the following error:
Could not find gem 'mysql2 (~> 0.2.6, runtime)' in any of the gem sources listed in your Gemfile. Run `bundle install` to install missing gems.
Then I run bundle install but could not happen.
I have installed:
Ruby 1.8.7
Rails 3.0.9 with mysql
RubyGems 1.8.7
I searched everywhere but nobody can solve my problem please help me with this issue as soon as possible. I am using Ubuntu 11.04.
Thanks in advance.
If your bundle install is saying everything is installed, try prefixing your rails command with
bundle exec rails server <other args here>
That will make sure you run the server in the context of the bundle (as defined by your Gemfile). If that fixes the problem for you, then you can either keep running the server using that command, or figure out what's wrong with your environment (might be a path issue, or you might have multiple versions of ruby or bundler installed and things aren't getting installed where you think they are)
i have reinstalled rails 4.2.4 using "gem install rails" command
and generated new project using rails new helloworld
"cd helloworld" and "rails server" would started my server.

Resources