Ruby -- run a local gem server - ruby-on-rails

I'm a Ruby novice working on a Rails application. We're trying to speed up our installs by running a local gem server instead of always going out to rubygems.org. I found that running the command:
gem server
sets this up, with the server running at localhost 8808. However when I add a source line for that URL to my Gemfile, and then run "bundle install", it fails after a minute or so saying:
Gem::RemoteFetcher::FetchError: bad response Not Found 404 (http://localhost:8808/gems/rake-10.3.1.gem)
An error occurred while installing rake (10.3.1), and Bundler cannot continue.
Make sure that `gem install rake -v '10.3.1'` succeeds before bundling.
If I browse to that server, I see a page saying that Rake, version 10.3.1 is installed, but when I go to the listed URL, I do get a 404 page. After running the gem install command, I still get a 404 page, but the bundle install gets a step further and fails with:
Gem::RemoteFetcher::FetchError: bad response Not Found 404 (http://localhost:8808/gems/activesupport-3.2.12.gem)
An error occurred while installing activesupport (3.2.12), and Bundler cannot continue.
Make sure that `gem install activesupport -v '3.2.12'` succeeds before bundling.
What's going on here? I have both source lines in my Gemfile, so I'd expect the bundler to go out to rubygems.org for anything it couldn't find locally, but it also seems like the gems are in fact installed locally already. Do I have to run individual installs on each gem dependency? I'm sure I'm doing something obviously wrong here, but I'm don't know what it is.

This is a decent walkthrough of a few situations you might encounter while setting up a gem server: http://guides.rubygems.org/run-your-own-gem-server/
This one isn't half-bad either, if you're looking to just use local versions of gems (though this technique doesn't set up a separate gem server): https://coderwall.com/p/tqdrhq

Related

Bundle Install trying to install gem not in Gemfile

I have a strange problem. I cloned a working rails repository from github.
It had a gemfile with certain gems and "debugger" was not one of them.
However when i ran "bundle install" it error out
An error occurred while installing debugger (1.6.8), and Bundler cannot
continue.
Make sure that `gem install debugger -v '1.6.8'` succeeds before bundling.
So i deleted the Gemlock file which had a reference to the debugger. Now i try to do "bundle install"again. I am getting the same error.
I am using ruby 2.1 and debugger is not compatible with it and everybody seems to be moving byebug. However im not able to move away from debugger as my bundler wont let me.
Any thoughts.

Rails installation on hostmonster bundle install fails

So I had a rails app up and working on my hostmonster account just fine. I then updated a few things in my dev environment / pushed them up to github / pulled them back down on my production environment. Now its giving me the error Could not find pg-0.17.1 in any of the sources (Bundler::GemNotFound).
This is a new gem i installed in my dev because i was attempting to move to postgresql for dev and live....for now im using postgresql in dev and mysql2 in production. I know this isn't optimal but im working on it.
I tried running bundle install to get the pg gem installed and it fails with the error
Gem::Exception: Cannot load gem at [/usr/lib64/ruby/gems/1.9.3/cache/rake-10.2.2.gem] in /home4/muscorei/workspace/vollapp
An error occurred while installing rake (10.2.2), and Bundler cannot continue.
Make sure that gem install rake -v '10.2.2' succeeds before bundling.
I try installing rake and it works fine...try again..same error. I have found one question on here that seems to fix this for others but it requires running of gem update --system which you cannot do for hostmonster. Any ideas?
So here is another "related" issue. When i type in gem list --local I see that rails is installed at version 4.1.0....however when i do rails -v it shows the systemwide version of 3.2.13. I don't EVER have any of these annoying issues on my dev environment.

AWS rugy gem seems to be failing on heroku and locally

Anyonw have any idea what's happening with the aws-sdk gem. I noticed this popped up in one of my applications today and it's effecting more then one now. I get the same error in all app's yet the link to the gem seems to be working.
On Heroku
Gem::RemoteFetcher::FetchError: bad response Not Found 404 (https://s3.amazonaws.com/production.s3.rubygems.org/gems/aws-sdk-1.19.0.gem)
An error occurred while installing aws-sdk (1.19.0), and Bundler cannot
continue.
Make sure that `gem install aws-sdk -v '1.19.0'` succeeds before bundling.
!
! Failed to install gems via Bundler.
!
! Push rejected, failed to compile Ruby/Rails app
And locally:
$ gem install aws-sdk
ERROR: While executing gem ... (Gem::RemoteFetcher::FetchError)
bad response Not Found 404 (http://production.cf.rubygems.org/gems/aws-sdk-1.19.0.gem)
Thanks in advance.
Looks like a botched deploy of some kind, version 1.18.0 looks like it's available. 1.19.0 was released today, do you really need to be using that version? Did you do a bundle update across your whole application or something that may have forced all gems to update? Don't do that! :)
Might want to let them know: https://github.com/aws/aws-sdk-ruby

Bundle install gives errors on many gems

when i try to run a bundle install on a catarse project on my VPS, many of the gems needed for this project returns errors and i can't install (i'm using: ruby 1.9.2p320).
for example the gems thats return error are:
thin
eventmachine
linecache19
the error is always something that begins with:
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
and ends with:
Gem files will remain installed in /usr/local/rvm/gems/ruby-1.9.2-p320#catarse/gems/linecache19-0.5.12 for inspection.
Results logged to /usr/local/rvm/gems/ruby-1.9.2-p320#catarse/gems/linecache19-0.5.12/ext/trace_nums/gem_make.out
An error occurred while installing linecache19 (0.5.12), and Bundler cannot continue.
Make sure that `gem install linecache19 -v '0.5.12'` succeeds before bundling.
can you help to figure out?
Some gems need to be built locally rather than simply downloaded. This means that some of the code in the gem is written in something other than ruby (usually C). The non-ruby code needs to be compiled and built locally in order to run. In those cases you'll need an environment that is capable of compiling and building that non-ruby code.
There's a good post about native gems here : http://patshaughnessy.net/2011/10/31/dont-be-terrified-of-building-native-extensions.
In cases like these it is usually question of tracking down which libraries need to be installed locally in order to build the gem.
I am aware of some issues with linecache19 and there are questions out there that address these, for example : Installing linecache19 for Ruby 1.9.2 via rvm.

bundle install request to do each gem install manually - how to avoid?

This is probably very simple question.
Each time I do "Bundle install" in the folder of the project
I get an error like this
An error occured while installing json (1.6.6), and Bundler cannot continue.
Make sure that X succeeds before bundling.
where X can be
'gem install json -v '1.6.6'
or
'gem install execjs -v '1.3.2'
or
'gem install coffee-script -v '2.2.0'
Now, after I gradualy do each gem install manually the bundle install succeeds.
Is there a way to do them all in one command?
is there a way to do it in ruby mine?
That's what Bundler is supposed to do for you.
It looks like you have a problem with your Bundler or Ruby Install somewhere.
Without more information I can only suggest that you checkout the Bundler Troubleshooting page.
I've run into the same problem before if my network connection was an unstable/low bandwidth wireless connection. It tries to install all the gems at once, but stalls on one of them because of the lack of bandwidth. Then you can of course install one at a time maybe, but if your connection keeps going in and out this may be the cause of your inability to install them all at once.
It's possible that some of your gems aren't getting installed due to a bug related to using SSL connections. This would then mean that gems that depend on those gems throw an error like the one you experienced.
See: http://railsapps.github.com/openssl-certificate-verify-failed.html
That link has various workarounds, but the easiest is to replace this line:
source 'https://rubygems.org'
at the top of your Gemfile with this line:
source 'http://rubygems.org'

Resources