Windows system can't call ruby or gem - ruby

After I installed ruby, type ruby ​​or gem in cmd and there is no such command.
And I have added the installation path to the system environment.

I did this, but it didn't work. But now it's done, because I installed ruby ​​on a non-system disk before, so there will be some strange problems.

Related

rbenv clobbering my gem INSTALLATION DIRECTORY when using system

I want to use rbenv for setting ruby versions on a project per project basis. Otherwise, I want to use my default system ruby setup for everything else.
The problem I am having is the even though rbenv version returns system, gem command still uses the rbenv shim (.rbenv/shims/gem). So when I do gem environment my INSTALLATION DIRECTORY is '/Library/Ruby/Gems/1.8'. I would rather it remains ~/.gem/. I can see it still is that when I run /usr/bin/gem enviroment. I can't figure out where the rbenv shim gem is getting its settings from.
I've tried modifying my GEM_HOME both in my shell, and changing it in ~/.gemrc but that has no effect. I've been searching around with no luck. Hopefully someone here can help. Just some pointers to where the rbenv gem shim is pulling its values from would be helpful.
thanks
Since rbenv shims are pretty high in your PATH, their purpose is to intercept any invocation of ruby, gem, and similar, even if the currently selected Ruby version is "system". You shouldn't be worried about that.
Now, the default installation path for your system Ruby will always be /Library/Ruby/Gems/1.8. Here's my RBENV_VERSION=system gem env:
- GEM PATHS:
- /Library/Ruby/Gems/1.8
- /Users/mislav/.gem/ruby/1.8
- /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8
However, if you don't use sudo (and you shouldn't), gem install won't have write access to that directory, and will install the gems in the next writeable path, which is ~/.gem/ruby/1.8. That seems to be the behavior you want.

Multiple installs of Ruby -- how to solve in OS X

I'm having problems with Ruby scripts finding the right gems. It seems this is related to having multiple installs of Ruby on my system. OS X already comes with Ruby but it's not the latest one. I upgraded from Snow Leopard to Lion and suddenly have all these instances of the rubygems folders:
/Developer/SDKs/MacOSX10.6.sdk/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems
/Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems
/Library/Ruby/Gems/1.8/gems/rubygems-update-1.8.11/lib/rubygems
/Library/Frameworks/MacRuby.framework/Versions/0.10/usr/lib/ruby/1.9.2/rubygems
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems
/Users/[user_name]/.rvm/repos/ruby/lib/rubygems
I installed the graph gem with gem install and I can't seem to find it in any of these locations. irb finds it when I do a require but a ruby script saved and run from the CLI produces the error:
'require': no such file to load
Another clue is that when running rails server I often see output from /Library/Ruby/Gems/1.8/gems/
But the graph gem doesn't seem to be in that path either.
So, yes a big mess. Any help to safely simplify this and remove the redundant instances would be greatly appreciated.
Update:
Was able to track the installed gems to:
/System/Library/Frameworks/Ruby.framework/Versions/Current/usr/lib/ruby/user-gems/1.8/gems
So should I just delete everything else with a rm -rf? I'd hate to do that and cause all sorts of dependency problems. Ultimately I'd like to end up with a clean system with only one ruby install but I cannot wipe out my hard drive.
I recommend you use rvm to switch rubies and gems. put a .rvmrc into your project folders and it will switch a "gemset" automatically for you.
The general consensus is to leave the ruby version of the os as it is an use either rvm or rbenv to switch ruby versions.
It does look like you have rvm installed as well as multiple ruby installation installed in different ways too.
Does rvm work correctly, if so you can ignore your other ruby installations.

Can RVM find versions of ruby it did not install?

I'm running os x lion. A version of ruby was installed when I installed the OS. I then installed RVM and then installed ruby 1.9.2 and made it the default for new shells.
Default Ruby (for new shells)
ruby-1.9.2-p290 [ x86_64 ]
What happend to the older version of Ruby that was already on my system and how can I remove it since RVM doesn't see it?
When I try to use the new hash syntax in code written in textmate or sublime text 2 it fails. When the same code is run in the shell it works. So how do I make ruby 1.9.2 the only ruby installed on my system?
You do NOT want to uninstall the system Ruby. It is required for a lot of applications (including RVM) to function properly.
If you want applications like Textmate or Sublime Text to use a different version of Ruby, you can update their individual configuration settings to set the path to the Ruby binary you wish to use.
Since those apps don't run ruby from the shell like you do they don't work seamlessly with RVM. Fortunately RVM's web site has instructions on integrating RVM with TextMate. You shouldn't have trouble applying the same process for Sublime Text 2 but if you do the web does not want for tutorials on the topic.
Also, RVM is not responsible for any ruby it didn't install. the only other ruby it gives access to is the system ruby, and there it doesn't do gemsets etc. (This is also due to systems like debian that specifically block off things like gem update --system so you don't poison the package that was installed. RVM protects from that as well)

Can't see the binary after installing ruby gem: memcached

I need to install and run memcached for an application. I have my own ruby installation on a linux machine I am not a super-user of.
My ruby installation is in ~/ruby-install which also has the ruby-gem binary installed. Now, from here, when I do a `gem install memcached', I do not see any error and it seems that the gem installation went well.
However, I'm a bit puzzled as to what post-install environment setup should I do to get the memcached commandline working?
Execute
cd `gem environment gemdir`
cd bin
ls
If that dons't display the program your looking for, I don't know whats wrong. Otherwise, just execute from here. All command line tools installed by Rubygems live here in the bin directory.
You can also add the gemdir to your $PATH. That will allow you to execute tools anywhere.

Error installing AWS SDK for Ruby on Mac

I'm learning Ruby to access an AWS SDB created by my partner. When I installed the AWS SDK for Ruby on my Mac, I got the following message:
WARNING: Installing to ~/.gem since /Library/Ruby/Gems/1.8 and
/usr/bin aren't both writable.
WARNING: You don't have /Users/royclymer/.gem/ruby/1.8/bin in your PATH,
gem executables will not run.
I'm familiar with "PATH" from my PC days but have just started using Terminal on the Mac (to run Ruby) and can't find PATH command there. Maybe this isn't a problem, because it did say "six gems installed" but I also got several statements like "No definition for get_options."
Thanks.
It sounds like you are trying to install a gem into your system install ruby. You can likely resolve this issue by prefixing the gem install command with sudo.
sudo gem install aws-sdk
While this should work, its generally better to use a different solution that does not require installing gems as root (try googling rvm and rbenv).
PATH is not a command, it's an environment variable. To see the current content, do echo $PATH in your terminal. To temporarily change your PATH you can just re-export it like so:
export PATH=~/.gem:$PATH
For a permanent change you may want to read up on .bash_profile or .bashrc as well as /etc/paths and /etc/paths.d/.

Resources