My gem commands keep pointing to a wrong server - ruby-on-rails

Any time I run a gem command (gem install, gem list, etc) I get the following error:
ERROR: While executing gem ... (Gem::RemoteFetcher::FetchError)
Errno::ENETUNREACH: Network is unreachable - connect(2) (<internal_server_at_work>)
A while back, before I finally got around to learning Rails, one of the developers made a gem for a project and I made some sort of change to add that server to my gem repositories.
I have no idea where that is. My Gemfile in the project I'm using to teach myself Rails puts rubygems.org as the source. Is there a master Gemfile of some sort?
Thanks

The Gemfile.lock specifies some of this information. Deleting it and rerunning bundle install may resolve the problem.

You can always try bundle update gem_name. Also, it is possible to point it to the exact URL.
gem some_gem, :git => "another url"
You could also paste your Gemfile for us to help you out better. :)

Related

Checking out from GitHub a specific reference within a Ruby Gemfile

So, I have no Ruby experience at all. However, I'm being asked to look after some Ruby on Rails / Ruby source code that was left behind by my predecessor. I'd like to at least get it to install and run within its Docker container.
From what I can tell, it is failing because of the mimemagic problem from a couple of years ago. It has a dependency on mimemagic v0.3.0 . I know the right thing to do would be to move on to the recent versions that have not been yanked. But, with my limited experience with Ruby, I'd like to at least get my predecessor's code to install and run.
Since moving up to the earliest mimemagic that is available (v0.3.7) appears to break other things, I have been trying to install v0.3.0 using the GitHub reference as a work around.
This:
gem 'mimemagic', github: 'mimemagicrb/mimemagic', ref: 'a4b038c6c1b9d76dac33d5711d28aaa9b4c42c66'
complains that I'm transmitting without encryption. It ultimately fails to fetch with a connection time out.
Meanwhile, this:
gem 'mimemagic', git: 'git#github.com:mimemagicrb/mimemagic.git', ref: 'a4b038c6c1b9d76dac33d5711d28aaa9b4c42c66'
complains that the host key verification has failed.
Finally, this gets me a little further:
gem 'mimemagic', git: 'https://github.com/mimemagicrb/mimemagic.git', ref: 'a4b038c6c1b9d76dac33d5711d28aaa9b4c42c66'
but an error later on looks like this:
rake aborted!
Bundler::GitError: The git source https://github.com/mimemagicrb/mimemagic.git is not yet checked out. Please run `bundle install` before trying to start your application
I have this feeling that "quickly getting it to work" isn't a reality and perhaps all of this will take a lot more than the 1-2 days I've spent so far. I just would like to check what the correct gem/git commands are, and if any of the above three are close.
Thank you!
As the error suggests, you must run the bundle install command before starting the application server or accessing the console.
The reference in the Gemfile is added correctly.
gem 'mimemagic', git: 'https://github.com/mimemagicrb/mimemagic.git', ref: 'a4b038c6c1b9d76dac33d5711d28aaa9b4c42c66'
If you've already executed the mentioned command, can you update the question to have the output for this command?
P.S. Read more about the bundle install command here.

rails server command doesn't run

I am trying to run the rails server on windows instance (I am using gitbash). I already install ruby (1.9.3), rails(4.2.0) and gem (1.8.29). I have took a screen shots of my error and my Gemfiles so you guys can look at it. I dig into the error and it seems like PTY files which are required on the slave.rb files is not supported on the windows! Does anyone know the way around this problem?
Thanks!
To solve this for the time being comment out the web-console gem as this has reference to the pty gem but please take note of my comment on your question
# gem 'web-console'
You might then want to run bundle install again

Ruby on Rails - How can I resolve this 'rake db:create' error?

I am trying to get a simple tutorial app up and running with Rails, but have run into this problem almost right away. I create the new ruby app, cd to the directory and run rake db:create. I get the following
Please install the sqlite3 adapter: 'gem install activerecord-sqlite3-adapter' (sqlite3 is not part of the bundle. Add it to the Gemfile.)
But I do have the gem added to the Gemfile, like so:
gem 'sqlite3'
Also, when I tried to gem install the adapter, I was given an output saying that it did not exist in any repository. This is my first time using rails, any ideas on how to fix this?
*Edit
gem install activerecord-sqlite3-adapter produces the following:
Error: Could not find a valid gem 'activerecord-sqlite3-adapter' in any repository.
The it offers some alternatives, only one of them being sqlite3. It is called activerecord-jdbcsqlite3-adapter. Is this the one I need possibly?
Thank you for everyone's input. I never was able to resolve this issue, and ended up just using the Rails Installer instead. So much easier, just make sure you delete all your previous versions of Rails, Ruby, Gems, everything. Then use the installer.

Bundle Install could not fetch specs from https://rubygems.org/

I'm attempting to follow the Hartl Rails Tutorial, and having trouble with the bundler gem.
When using the commands 'bundle install' or 'bundle update' I get the following output:
Fetching source index from https://rubygems.org/
Could not fetch specs from https://rubygems.org/
I've searched for this output, but did not find many related issues online.
Maybe I have another gem that is interrupting bundler? I have little experience with rails at this point.
source 'https://rubygems.org'
gem 'rails', '3.2.12'
group :development do
gem 'sqlite3', '1.3.5'
end
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '3.2.5'
gem 'coffee-rails', '3.2.2'
gem 'uglifier', '1.2.3'
end
gem 'jquery-rails', '2.0.2'
The solution for me was two parts: I changed https to http, and that temporarily solved the issue. The second issue was that I think I had a bad install of ruby 2.0.0 even though I was using a fresh install of ruby 1.9.3. So I reinstalled ruby 2.0.0, and I could use bundle install with https.
Just in case none of the above satisfies the next intrepid explorer, I thought I'd drop here that after I spent 4 hours on this doing variants of the search that landed me here, I finally discovering that IPV6 was the culprit, after finding this specific thread on help.rubygems.org. Solution? this (Fedora, Linux):
sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1
sudo sysctl -w net.ipv6.conf.default.disable_ipv6=1
set up a shell script to flip IPV6 on and off so I could run a command without it, and now everything runs peachy.
I had the same issue. The only working solution I found was to force http instead of https in Gemfile:
source 'http://rubygems.org'
you can try the following, if in windows:
set HTTP_PROXY= <your proxy address without http://>
set HTTPS_PROXY=%HTTP_PROXY%
For eg:
HTTP_PROXY=mycompany.myproxy.com:8080
HTTPS_PROXY=%HTTP_PROXY%
Worked for me
It can be temporary network issue as well.
Try restarting network services using command
service network restart
If its *nix machine.
I had the same issue using ruby-2.0.0-p247 on OS X 10.8.5.
Make sure the first line in Gemfile is using https://
source 'https://rubygems.org'
I reinstalled that version of ruby.
rvm reinstall ruby-2.0.0
Ruby was upgraded ruby-2.0.0-p598 (version depends on latest patch).
bundle then worked without error although all the gems were reinstalled.
Mine was just a simple network issue, just restart pc / router
The other reason causing such that issues is the fact if you are behind proxy server. I describe here solution, maybe it will be usefull for someone else. :)
In case that you did not know Login/pass for yours proxy, and meet this issues you could firstly check if you need to (re)install anything, by command:
C:\...> bundle check
Resolving dependencies...
The Gemfile's dependencies are satisfied
If you get other respons then above, you could find properly gems in properly versions here (rubygems.org), then install it (from the directory with downloaded gem) by command:
gem install <gem-name> --locally
Use wget to see if you can reach the domain
wget http://rubygems.org/latest_specs.4.8.gz
If this fails then try the following.
Edit your /etc/resolv.conf file and add these lines near the top to use Google's name servers
nameserver 8.8.8.8
nameserver 8.8.4.4
I had this issue while working in Cloud 9. After trying several 'bundle install' and sending an email to c9 support(no reply) I was able to get it working by killing all the processes and doing a hard-restart of the IDE.
Do this by clicking directly on the little bar-graphs at the top of the right-hand side that show CPU, Memory, Disk. Then click on the process list, select them all, and force kill. Then exit out of the process list. Click on the bar-graphs again, and this time click 'Restart'.
After this I was able to run bundle with no problems.
Either with http or https did not work.
After I disabled the IP
v6, it worked
https://support.purevpn.com/how-to-disable-ipv6-linuxubuntu
Adding variable for proxy worked fine.
Additionally if you are using Bitnami redmine like me you can add that into setenv.bat then when you start command line with Bitnami Redmine short cut it will be automatically added to your environment.
You can find this under Bitnami installation folder.
If you are using Cloud9, just restart (command R) and try again
Sometimes it happens due to proxy you are using.
I tried to resolve this by using a connection without proxy and all worked perfectly fine.
Then try:
bundle update
And then go for
bundle install
For me, restarting the computer worked. I had already reinstalled ruby, updated bundler, removed 's' https:// but none of them worked!
A very simple solution I've used recently to overcome Bundler::HTTPError Could not fetch specs from https://rubygems.org/ which doesn't require you to disable IPV6 globally in your system:
ping -4 rubygems.org - to get an IPV4 address
Add the following line to your /etc/hosts file (use whatever IP address from the previous command output cause it might change):
151.101.129.227 rubygems.org
I just had to restart my wifi and it started working.
CHange your source form https to http after run
sudo bundle update
sudo bundle install
In my case the source of the problem was VPN. Disconnecting from it helped to resolve the issue.

Gem install looks for misspelled gem name

I just installed the searchlogic gem, and when I run rake gems:install, I'm getting the following output:
gem install serachlogic
ERROR: could not find gem serachlogic locally or in a repository
Not the misspelling of "serachlogic". I don't think that's an error I introduced, but I'm not sure where I can fix it.
Any ideas? Thanks....
You probably have a typo in your Gemfile (if you use bundler) or config/environment.rb.
If all else fails, open up your editor and search all your project code for serachlogic to see where the problem is located.

Resources