'no such name' error on all gem install attempts - ruby

I just installed Ruby 2.2.2 on a Windows 7 64-bit VM. Every gem install <gemname> attempt fails with the following error:
ERROR: Could not find a valid gem '<gemname>' ()= 0), here is why:
Unable to download data from https://rubygems.org/ - no such name
(https://api.rubygems.org/specs.4.8.gz)
However, the list generated by the gem list contains the gem that I thought failed. Is it actually installed or not? I assume it isn't but even if it is, the error concerns me.
I know that I am working behind a proxy so I've tried appending --http-proxy but that hasn't helped either.
Any ideas to troubleshoot this? Thanks!

It's possible that one of the gems that you installed declares an invalid dependency such as <gemname> (specifically).
To validate this, open an irb or pry console and run Gem.loaded_specs to see if the string <gemname> shows up anywhere.
You could also try updating your rubygems with gem update --system.
And finally, you could also try to run gem check to validate all installed gems.
Unfortunately, this appears to be an issue that needs to be investigated to get to the root cause.

I ran into the same issue before figuring out my session was fucked up. Indeed the command whoami was displaying an id and not my username. I logged out and logged in again and everything was solved.

Related

Trying to put bundle in PATH

I'm working on a Ruby project that requires the use of a few gems. I'm a bit confused, since I thought I already had bundler installed on my Mac. I tried installing it just now and got the following error:
Leias-MacBook-Pro:spec leia$ gem install bundler
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.3.0 directory.
I then tried using --user-install, a trick I picked up from browsing Stack Overflow.
Leias-MacBook-Pro:spec leia$ gem install bundler --user-install
WARNING: You don't have /Users/leia/.gem/ruby/2.3.0/bin in your PATH, gem executables will not run.
Successfully installed bundler-2.0.2
Parsing documentation for bundler-2.0.2
Done installing documentation for bundler after 5 seconds
1 gem installed
Now, I kind of need the gem executables to run, so I opened my .bash_profile and dropped the following code in:
export PATH=/Users/leia/.gem/ruby/2.3.0/bin:$PATH
But no matter how I try to fix it, bundle still won't run. The gem I'm installing is rspec, and I definitely need to be able to run those executables. Am I doing something wrong here? I've tried to follow tutorials and Google similar issues, but I can't figure out what the problem is. Any pointers or suggestions?

unable to run a gem through terminal

I uploaded my first gem into rubygems. The code is tested and the gemspec is fine. It is in rubygems and rubydoc. I installed it on my machine via gem install [gem_name]. gem list lists it. However [gem_name] command yields gem_name: command not found.
YET: gem '[gem_name]','~>[version_num]' yields: ERROR: While executing gem ... (Gem::CommandLineError)
Unknown command gem_name,~>version_num
(aside: I could've sworn when I first published I played with it and gem_name worked flawlessly to run my gem...)
what can I do to diagnose this problem? Please advise.
EDIT: require '[gem_name]' works flawlessly in IRB. It runs smoothly (interacts with user). Once finished, it returns true. When I require other gems, eg require '[another_gem]' true is returned immediately. The code doesn't actually run. Perhaps this shed some light?
gem gem_name or gem_name is not a command. If you are trying to check if the gem installed properly, try gem_name -v. Also, depends on what flags and args your gem takes.
You are getting that error becausegem gem_name is not a command.
For eg: You do a gem install rails. Then you don't just do gem rails to run it. You do rails some_command or flag, etc. Like rails new blog.
Do other gems run properly? If not, the issue may be with your path. If you run the gem from the folder it is located in, does it still yield problems? Hope this helps!

Gemfile issues and Ruby install issues

I am working on a Windows 7 64-bit machine. I had Ruby version 2.1.5 installed on my machine and everything was working great. I went and installed a gem that would set up a project for you with most of the basics already completed, but it required Ruby 2.2.2. I went and researched how to upgrade my Ruby version and the best solution I found was to install the Pik gem for windows and install 2.2.2 separately, and switch between the two versions.
I followed a tutorial on YouTube for how to set up Pik. I normally use Git Bash but the tutorial required me to use the cmd.exe prompt to set up Pik, and then it included a way to use Pik with Git Bash at the end of the tutorial. I also had to add a file to my PATH in the system settings.
I was able to set up Pik and everything worked great with Pik on both the cmd.exe and Git Bash consoles. However, from there if I went to run any other commands such as bundle install, I would get an error:
Could not locate gemfile.
I have also experienced the same error, but it would say something along the lines of an issue with the .bundle/directory. I tried switching to a project that I had already created in the past and tried running the command again. It still had the same error. (I did this to see if the gemfile in the project would fix anything.) If I try running gem install rails, I have had it work once or twice - but I still have the 'no gemfile' issue after the fact.
The times the command doesn't work I often get:
ERROR: Could not find a valid gem 'rails' (>= 0), here is why:
Unable to download data from https://rubygems.org/ - SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B:
certificate verify failed
(https://api.rubygems.org/latest_specs.4.8.gz).
I tried running the pik gem and pik gemsync commands to see if that would fix my issues but it did not.
I tried uninstalling Pik by doing the pik implode command and deleting the files it created. The issue still persisted. I tried uninstalling the 2.2.2 version of Ruby using the uninstall executable in the file, and deleting any left over file(s). The issue still persisted. I tried to uninstall and reinstall Ruby completely from my machine, the 2.1.5 version that is doing the same method as the 2.2.2 version. Yet the issue still persists no matter what I do. I have tried many times uninstalling and reinstalling both Ruby versions, from the executable and from the control panel. I would like to find a way to completely uninstall and reinstall all of Ruby if possible, preferably reinstall Ruby 2.2.2. Or if anyone else has any other ideas for how to fix this issue?
from there if I went to run any other commands such as bundle install I would get an error Could not locate Gemfile.
As you've guessed, you need a file named gemfile in the same location you are running bundle install from
If I try running gem install rails I have had it work once or twice but I still have the no gemfile issue after the fact.
Running gem install <package> doesn't create a gemfile for you. You need to do this yourself. It's essentially a file where you manually specify which packages you would like your project to use. See here on how to create.
The times the command doesn't work I often get: "ERROR: Could not find a valid gem 'rails' (>= 0), here is why: Unable to download data from https://rubygems.org/ - SSL_connect retur ned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed ( https://api.rubygems.org/latest_specs.4.8.gz)."
This sometimes happens on Windows machine. You can do a quick search on how to fix the gem command with SSL, or in your Gemfile you can temporarily specify http://rubygems.org/ instead of https://rubygems.org/

Installing mysql2 gem on Windows 8

I'm trying to install the mysql2 gem on Windows 8 (Ruby 1.9.3 and Rails 4.0.1). I've installed the Devkit and it's working properly, and I'm entering the following:
gem install mysql2 --platform=ruby -- '--with-mysql-lib="C:\mysql-connector\lib" --with-mysql-include="C:\mysql-connector\include" --with-mysql-dir="C:\mysql-conector"'
I've done this before and it's worked, but for some reason this time it's throwing this bizarre message:
Cannot find include dir at C:\mysql-connector\include;C:\mysql-connector\include;C:\mysql-connector/include;
This is of course in addition to the whole "Could not create makefile for some reason..." message. I'm using the mysql connector that I found through a different post here--Ruby MYSQL2 gem installation on windows 7
Does anyone know how I can fix this? I really need this gem...
I figured this out...
All I had to do was:
gem install mysql2 --platform=ruby -- '--with-mysql-dir="C:\mysql-connector\"'
Strange though--last time it worked with the code above... Go figure...
I just ran into the exact same issue trying to install mysql2 0.3.14 on Window 64bit, Rails 3.2.15 and Ruby 2.0.0p247. I used a command very simliar to what user2986379 posted and it worked; literally 5 minutes later when I had to rerun the command to fix another issue it stopped working. I was even copying the command from notepad each time so there wasn't a typo. Odd.
Anyway, user2986379's solution of adding quotes to the paths helped me get past the issue, but I was still getting some errors. I ended up modifying the command by removing the single quotes. In case anyone needs it, here's the command I ran:
gem install mysql2 --platform=ruby -- --with-mysql-dir="C:\mysql-connector"
Lastly, just for completeness, I had to use the version of connector c located here. You can read more about why this is necessary at the bottom of https://github.com/brianmario/mysql2/issues/372. It will install fine, but without the special connector_c you might get a segmentation fault when you go to actually use the gem. (Don't forget to grab the libmysql.dll out of that special connector c zip file as well and place it in your ruby bin directory.)

Trouble with sqlite3 ruby 2.0 on Windows

I'm a newbie to programming, with ruby/rails successfully installed on my (mac) home computer. I'm trying to get ruby 2.0.0p195 (and Rails) set up on Windows at work (Windows 7, 32bit) and I'm failing on the sqlite3 installation. I've been through most of the solutions/suggestions I can find on the web, but just can't get it to work - the frustrating thing is that it tells me it's installed, but it doesn't work:
- I've tried the knapsack installation http://www.ruby-forum.com/topic/4413168
- If I try to install --with-opt-dir=c:/sqlite3 (or any of the many variations suggested) it gives a native extension error.
- I've put the .dll file in Ruby/bin, which is also in my PATH
- I have the devkit installed
The 'gem install sqlite3' command is successful, and if I do 'gem list', sqlite3 v1.3.7 x86-mingw32 appears in the list, but if I 'require sqlite3' in IRB I get:
LoadError: cannot load such file -- sqlite3/sqlite3_native
And the mkmf log says:
find_header: checking for sqlite3.h... -------------------- no
But I've confirmed the sqlite3.h file (and the sqlite3.c, sqlite3.o, and sqlite3.h files) is in my c:\sqlite3 directory, and as noted above, I've also tried installing '--with-opt-dir'.
So next I trace the error when I 'require' sqlite to a file '\kernel_require.rb' in ruby/lib, and it references to this:
if Gem::Specification.unresolved_deps.empty? then
return gem_original_require(path)
end
I'm lost, and WAY out of my depth. At this point my only solution would be either to completely uninstall and start again, or to downgrade to ruby 1.9.x, but others seem to have sqlite3 and ruby 2.0 working so it's obviously (?) semi-stable. Help?
UPDATE: I've now tried downgrading to ruby 1.9.3, and apart from pik reverting to the most recent version of ruby every time I shut the command line, I can actually get the server to run etc. So it seems this issue is related specifically to ruby 2.0.
I am encountering the same issue, except that I don't really think that it is related to Ruby 2, but to rails 4 instead.
I have managed to install the sqlite3 gem by downloading the source, dll and exec (dll and executables need to be added to PATH accessible) and installying the gem with the follwing process:
Download:
http://www.sqlite.org/2013/sqlite-amalgamation-3071700.zip
http://www.sqlite.org/2013/sqlite-dll-win32-x86-3071700.zip
Extract and put the files in a location on your C drive or wherever you want. Then copy sqlite.dll and sqlite.def to the Ruby/bin directory.
Then you go to the DevKit directory and run msys.bat, in which you issue the following command:
gem install sqlite3 --platform=ruby -- --with-sqlite3-dir=path-to-sqlite --with-sqlite3-include=path-to-sqlite
This allowed me to install the gem successfully (using Ruby-2.0.0-p247 x86 and devkit). I validated through irb doing:
require 'sqlite3'
SQLite3::SQLITE_VERSION
I'm still trying to figure out this issue.
I get the same error message when I try to start the server or whenever I try to run the rails console.
I'd love to get this issue fixed...

Resources