Could not find gem 'rails' headaches - ruby-on-rails

I'm on Mac OS X 10.6 Snow Leopard. I just updated my Ruby stuff using:
sudo gem update
Unfortunately, it broke everything. When I try to run a simple command in my website directory, like:
rails generate model User
It failed, with this error:
Could not find gem 'rails (= 3.0.3, runtime)' in any of the gem sources listed in your Gemfile.
Try running bundle install.
So I tried running bundle install rails. It succeeded! So I tried running rails. It failed. So I tried getting the Rails version by entering:
rails -v
Which failed with this error:
Could not find rake-0.8.7 in any of the sources
Try running bundle install.
But not only did it fail, it also created an empty folder rails/ruby/1.8 in my website directory.
This is a complete disaster for me as I am just a beginner in Ruby and Ruby on Rails, and even in the Terminal. Any help would be MUCH appreciated. Thanks.

all this stems from having a version of rack that is not exactly 1.0.1 iirc.
Even if you have a version ahead of it, your whole setup will not install properly.
Uninstall all versions of rack and make sure you only have that one.
As Justin said in your comments, now get rvm. Run, don't walk.

Related

Upgrading rails on Mac

I know the question to this is probably very straight forward, but Im a bit new to rails, so please bear with me. I have had rails version 5.1.5 on my Mac and I need to update rails to version 5.1.6 and I'm not able for the life of me to do that.
I tried
`sudo gem install rails -v 5.1.6`
but this gives the error
ERROR: Failed to build gem native extension.
Using gem list gives that I have
rails (5.1.5, 5.1.4)
I also tried bundle update rails
I keep getting Could not locate Gemfile
What am I doing wrong??
gem is the native package manager for Ruby.
Bundler (bundle) is a gem to manage bundles of gems via a Gemfile.
I recommend you use a version manager for Ruby like rvm, rbenv or chruby and also install xcode and the commandline-tools package of xcode. Some gems have dependencies written in C that need to be configured and compiled, all of that and some more comes with xcode.

Ruby on rails new app is not creating

I started to develop the new RoR web app and faced weird issue.
I wanted to create new app with Postgresql. So I installed the Postgres with brew and MacOS desktop app. And type rails new test-app --database=postgresql.
At this moment, I can't install bundles because there is certain
error.
An error occurred while installing pg (1.0.0), and Bundler cannot
continue.
Make sure that `gem install pg -v '1.0.0' --source
'https://rubygems.org/'` succeeds before bundling.
In Gemfile:
pg
run bundle exec spring binstub --all
Could not find gem 'pg (< 2.0, >= 0.18)' in any of the gem sources
listed in your Gemfile.
Run `bundle install` to install missing gems.
So I can't start new app.
Is this an issue that is occurring because of the mismatch between ruby and postgres version?
And how can I create new app with postgres?
I am currently using Mac OS high Sierra, postgres 10.5, rails 5.2.1
Try to skip running Bundler: rails new test-app --database=postgresql --skip-bundle
Once you've generated your app, you'll still have to troubleshoot why pg ins't installing. The PG gem should install just fine as long as the database is there and your system can build the gem's native extensions, so my first guess is either Postgres isn't installed or it can't be found in your environment.
Either way, this does answer your question. Skip the bundle and voila - Rails will generate a new clean app for you.
I've posted some comments, but i already seen that it seems to be an error when installing postgresql via brew. It's not common, but it happens sometimes.
Here's a quick fix:
brew install libpqxx
Make sure to run also
brew update
and restart your PostgreSQL server via:
brew services restart postgresql
Also make sure to clean up brew:
brew cleanup
If the error is still there, post your Gemfile and your database.yml file as well.
Greetings!

no metadata found in activereocrd-3.2.9.gem when running bundle install in a rails 3.2.9

am a newbie in rails. working on Windows 7, 64 bits. Installed my environment through RailsInstaller. latest version ofcourse.
When creating a new project, (keeping the gem file as default) and having the bundle install run, am getting the error
gem::package::FormatError: no metadata found in
D:/RailsInstaller/Ruby1.9.3/bin/cashe/activereocrd-3.2.9.gem
and error occurrend while installing activerecord (3.2.9), and bubndler cannot continue.
Make sure that gem install activerecord -v '3.2.9' succeeds before building.
I tried to run the gem install activerecord..as instructed still bundle install does not work and i cannot run the rails server. (rails s)
When changing the rails version in the app gem file to 3.2.8 instead of 3.2.9 everything seems to work and the rails server runs succefully. What is wrong?
I uninstalled railsinstaller and all other leftover folders.
reinstalled railsinstaller. Problem solved.

Bundler and Rails looking at different gems?

This has driven me crazy. I changed laptop and tried getting my Rails environment working again. Mac OS X has its own ruby, but I used brew and installed new. I installed rails 3.0.5, ran:
bundle install
Then:
rails s
I got this error:
Could not find aws-s3-0.6.2 in any of the sources
Run `bundle install` to install missing gems.
After bashing my head against a wall for a couple hours, I tried just manually installing the gems and it worked! So, apparently, rails and bundler are looking at different places for my gems. Both are from my brew install.
How can I figure out what each is looking at so I can use "bundle install" again?
Rails and Bundle are looking at the gems providing they are in the bundle.
Use the
bundle show
command to see the gems Rails is having access to via bundler.
Also you can examine the Gemfile.lock file.
The gemfile sources mainly from rubygems.org as supposed to rubyforge (which came up when i searched that gem on google). I think the gem command will check both. You can specify additional sources, as mentioned in the readme: http://gembundler.com/man/gemfile.5.html
Are you using pow? I've been having this issue with Pow starting up with one version of ruby, but not the version that I have RVM currently set to.
I have not tried it yet, but this issue on Github mentions the problem and refers people to the Pow trouble shooting here. I've pasted the contents below:
RVM
Incorrect ruby or gemset is being used
Create a .rvmrc at your project root. See rvmrc docs.
System-wide RVM install
If you have a system-wide RVM install and are getting the error LoadError: no such file to load -- bundler/setup, run rvm info to find out where rvm is installed on your machine, then do this:
echo "export POW_RVM_PATH=/usr/local/rvm/scripts/rvm" >> ~/.powconfig
Where /usr/local/rvm/ is the location of your rvm installation.
Then restart POW by killing it in the Activity Monitor or in Terminal.

Installed Rails Gem not loading

I'm very new to Rails (and Ruby), and am having trouble installing and using gems. I'm trying to use ruby-tmdb (https://github.com/aarongough/ruby-tmdb) and there's very little documentation.
"sudo gem install ruby-tmdb" runs just fine and I can see the gem installed when I run "gem list --local"
But, when I try and run the app, I get the error "no such file to load -- ruby-tmdb".
I'm on Mac OS X Snow Leopard. Ruby 1.8.7. Rails 3.0.3. Gem 1.3.7.
Is the gem listed in your Gemfile? In Rails 3, all gem dependencies should be listed in the Gemfile, so that it is properly loaded when the app runs.
You should have something like the following line:
gem 'ruby-tmdb'
Then, run bundle install to ensure that all gem dependencies are installed, and to have Bundler save the lock file that will ensure that all copies of this application run with the same gem versions. From this point on, you will no longer have to write the require line yourself; Rails will load in all necessary gems as the environment loads.
You might get the same error even after this, but it's always worth going through the standard process to help narrow things down :)
$ sudo which gem
$ which gem
$ sudo ruby -v
$ ruby -v
Sometimes users have different gems and rubys compared to root.
A common problem is that a gem installed for ruby 1.8 by root isn't visible for the users ruby 1.9
gems for ruby 1.8 and gems for 1.9 are NOT compatible.
This probably isn't the issue but is something that may be worth considering.

Resources