How to install RVM on macOS Big Sur with VS Code? - ruby

I'm trying to install any Ruby version manager, and then install Rubocop. "brew doctor" says my system is fine, and I recently upgraded laptops from MacOS High Sierra to Big Sur. (I'm on a new computer!)
I seem to have RVM installed correctly, and I have even tried and failed to get rbenv working. RVM is recommended by my software course for it's ease of use, and I'm following their notes, but here is my CLI code:
$ rvm --default use ruby-3.0.2_1
Required ruby-3.0.2_1 is not installed.
To install do: 'rvm install "ruby-3.0.2_1"'
$ rvm install "ruby-3.0.2_1"
Searching for binary rubies, this might take some time.
No binary rubies available for: osx/11.6/arm64/ruby-3.0.2_1.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Checking requirements for osx.
Installing requirements for osx.
mkdir: /usr/local/rvm/log/1637203871_ruby-3.0.2_1: Permission denied
tee: /usr/local/rvm/log/1637203871_ruby-3.0.2_1/update_system.log: No such file or directory
Updating system - please wait
Error running 'requirements_osx_brew_update_system ruby-3.0.2_1',
please read /usr/local/rvm/log/1637203871_ruby-3.0.2_1/update_system.log
Requirements installation failed with status: 1.
There's an old question and answer here that says the top part of my code isn't actually an error message, but I think the bottom part of it is saying I have some kind of issue.
Do I need to grant myself more permissions on this new laptop? Is the hint in the mkdir line above? Something else? How do I fix it? I would like to use an rvm to continue to use VS Code. I could switch to using AWS Cloud 9, but I prefer not to do that.

Related

How to fix gem permission error after installing rbenv?

I was trying to install Sinatra and I kept on getting this error: You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory
Thanks to "Installing gem or updating RubyGems fails with permissions error" I installed rbenv. I followed the guide and set my global ruby version, etc. but I continue to get the same error when I try to install gems. When I run gem environment the installation directory for RubyGems is still the system Ruby directory.
Should I update GEM_PATH? Since the rbenv guide doesn't mention anything about that, something makes me think that there is still a problem with my rbenv installation.
Can someone please help me figure this out?
You're not showing us the commands you're using but it smells like you're using sudo to install Sinatra. Don't do that with rbenv or RVM managed Rubies.
Just as in the linked question, using rbenv or RVM allows you have one or more Rubies in your user-space where you can modify them all you want. That means you don't need to use sudo, just use gem install ....
An alternate problem you could be having is you set your global Ruby to be system, which is the version installed by Apple for their use, and which you don't want to modify unless you understand why it's there and what they're using it for. IF you have to change it then sudo would be appropriate but, with rbenv or RVM managing Rubies in your user-space there's really no reason to.
Do NOT use chmod to change the ownership of the vendor installed gems; Again, that's for Apple's use so have fun with the local Rubies instead and leave Apple's alone.
In this case, I quit Terminal and upon reopening, things were working correctly. Probably a good thing to try if you're stuck and are sure you've followed instructions correctly. It's not explicitly mentioned in the material I read but I believe is a good practice in general.

Trying to uninstall and fresh install Ruby on Ubuntu: do I still have Ruby installed?

I'm coming from Windows to Linux (Ubuntu) so I'm new to the CLI. I had issues trying to install Rails so I figured a fresh install would help. I'm following "Installing Ruby the Correct Way."
I thought I had uninstalled Ruby, but after installing 2.1.4 it still shows some Ruby folders. Have I completely uninstalled Ruby?
Downloading ruby-2.1.4.tar.gz...
-> http://dqw8nmjcqpjn7.cloudfront.net/bf9952cdeb3a0c6a5a27745c9b4c0e5e264e92b669b2b08efb363f5156549204
Installing ruby-2.1.4...
Installed ruby-2.1.4 to /home/richard/.rbenv/versions/2.1.4
richard#richard-ThinkPad-T400:~$ rbenv global 2.1.4
richard#richard-ThinkPad-T400:~$ ruby -v
The program 'ruby' can be found in the following packages:
* ruby
* ruby1.8
Try: sudo apt-get install <selected package>
richard#richard-ThinkPad-T400:~$ sudo rbenv global 2.1.4
richard#richard-ThinkPad-T400:~$ ruby -v
The program 'ruby' can be found in the following packages:
* ruby
* ruby1.8
Try: sudo apt-get install <selected package>
Are the "the following packages" on my local system? or are they online?
EDIT
I've been getting this error when I try to install RVM (and some other applications):
GPG signature verification failed for '/home/richard/.rvm/archives/rvm-1.26.0.tgz' - 'https://github.com/wayneeseguin/rvm/releases/download/1.26.0/1.26.0.tar.gz.asc'!
try downloading the signatures:
gpg --keyserver hkp://keys.gnupg.net --recv-keys D39DC0E3
they can be compared with:
https://rvm.io/mpapis.asc
https://keybase.io/mpapis
Does this have anything to do with it? I wouldn't really think so but I'm a noob.
Don't sudo rbenv anything or you will summon Cthulhu. Use rbenv by itself.
Also, don't randomly follow guides on the internet until you're more familiar with your OS; They go stale, or start out wrong, or don't accurately apply to what you're doing. Instead, go to the source and follow the directions there.
To find out what is installed on your machine, use locate to quickly find Ruby instances. Something like:
locate /bin/ruby | grep -v .rbenv
should narrow down whether multiple Rubies are installed outside the ~/.rbenv directory.
Traditionally, you'll find a normally installed system-wide Ruby in /usr/bin/ruby. A user installed one from source will probably be in /usr/local/bin/ruby unless you specifically said otherwise, probably with a PREFIX= directive.
rbenv will default to installing Ruby in the ~/.rbenv hierarchy since it acts like a sandbox manager and will put all Rubies it installs underneath that directory. RVM, a similar application, will use ~/.rvm, and in both cases, the purpose is to keep them where the user's permissions are sufficient to install and update gems without requiring the use of sudo. For general use, avoid sudo unless you understand what you're about to do, as it can turn a computer into an under-desk heater in seconds.
The shell uses the PATH variable to figure out where to look for executable commands. It sounds like your PATH isn't set correctly. If you followed the directions on the rbenv site, they say how to enable rbenv by modifying your ~/.bash_profile script. Doing that, then closing and reopening your shell should bring rbenv to life.
Following that blog post, you are installing Ruby using a tool called rbenv, and if you only uninstalled one Ruby, that doesn't mean that all Rubies are uninstalled.
The message that you posted shows that it is a local install: Installed ruby-2.1.4 to /home/richard/.rbenv/versions/2.1.4 which is a copy of the 4th line of your message.
You can find out from whence your Ruby executable is being invoked by issuing at the command line:
which ruby
You will then know if the program is available and which it is. Using ruby -v if it is there will tell you the version.
You have done some of these steps and are finding out that your system does not know how to get to the Ruby, if it is indeed installed.
Right now, it is effectively uninstalled, as it is unavailable to your environment.

Ruby error on OS X Yosemite and chef

Getting this error when trying to install chef on OS X Yosemite, other gems have installed fine. Not seeing a requirement. Just wondering if anyone has and idea of what the issue is or has come across this.
$sudo gem install chef
Building native extensions. This could take a while...
ERROR: Error installing chef:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby -r ./siteconf20141023-4708-6api21.rb extconf.rb
creating Makefile
/Library/Ruby/Gems/2.0.0/gems/libyajl2-1.1.0/ext/libyajl2
extconf.rb:104:in `makemakefiles': unhandled exception
from extconf.rb:138:in `<main>'
extconf failed, exit code 1
EDIT: Although my answer below will help you install it on the system version of Ruby. I would probably suggest using RVM instead as the comment below mentions. I do not use Ruby very often and it would probably be fine, but I decided to take the 10 mins to change it to installing to RVM since that way I leave the system ruby untouched.
As I was searching across the web, I could actually resolve this issue (which also appeared on docker/ubuntu) as suggested in this thread:
https://stackoverflow.com/a/32191707/1948319
Long story short: The gmp library is missing. You can install it on ubuntu with
sudo apt-get install libgmp3-dev
I had this problem with this gem specifically, and another gem with c extensions as well.
Turns out I needed to accept new terms & conditions after updating XCode :-)
sudo xcodebuild -license
So I actually answered my own question very shortly after I posted and I hope it helps someone else in the future.
I used this instead:
$ sudo ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future gem install chef
The Apple LLVM compiler in Xcode treats unrecognized command-line options as errors. This issue has been seen when building both Python native extensions and Ruby Gems, where some invalid compiler options are currently specified.
Came across this issue which was similar enough:
https://github.com/FontCustom/fontcustom/issues/194

"Quick Install Gem" not working on RubyMine

I've just done a fresh install of RubyMine 4.5 in order to get a quickstart on Rails dev.
Whenever I try and install any Gem using the Tools > Quick Install Gem... command, I get the following error (below is specific to the flickraw gem)
Failed to Install Gems
Following gems were not installed:
flickraw(0.9.6): While executing gem ...
(Errno::EACCESS)
Permission denied - /Users/Andy/.rvm/gems/ruby-1.9.3-p194/cache/flickraw-0.9.6.gem
I guess I get that it's a permissions error...but why is it happening, shouldn't this just work? And how do I fix it?
I'm running this on the latest version of OSX Mountain Lion.
I've had similar problems before, it turned out to be caused by sudo being the owner of some gems installed in that rvm ruby installation I was using. I guess I installed something with sudo by accident, I dunno-- but go check in /Users/Andy/.rvm/gems/ruby-1.9.3-p194/cache and /Users/Andy/.rvm/gems/ruby-1.9.3-p194/gems and see if sudo owns cache/flickraw-0.9.6.gem or any folders in gems and if needed change the owner and group back to you ... I actually had so many messed up I opted to just remove and rebuild that ruby.

Error installing RedCloth

I'm getting this erron when trying to install RedCloth on openSuse:
sudo gem install RedCloth
Building native extensions. This could take a while...
ERROR: Error installing RedCloth:
ERROR: Failed to build gem native extension.
/usr/bin/ruby extconf.rb
creating Makefile
make
sh: make: nie znaleziono polecenia
Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/RedCloth-4.2.3 for inspection.
Results logged to /usr/lib/ruby/gems/1.8/gems/RedCloth-4.2.3/ext/redcloth_scan/gem_make.out
I tried to google this out and triend everything. So I need help with that.
I just had this same a similar problem and fixed it by installing the ruby dev package. For me, the command was:
sudo apt-get install ruby1.9.1-dev
I found the answer (and a better description of the problem) on this blog.
It's not the answer to this question exactly, but hopefully it'll be of use to someone else who stumbles upon this page.
If Google's Polish translation is correct, then you don't have make installed on your machine.
Try entering which make. If you see nothing, then you need to handle that first. I'm not sure the name of the package you need in OpenSuse. You should be able to search in Yum (Yast? whatever OpenSuse's package manager is called...) for something like Debian's 'build-essential' package.
Edit: In OpenSuse, the package you need seems to be called "C/C++ Development" (or "C/C++ Compiler and Tools"). See this thread for some pointers: http://forums.opensuse.org/applications/413553-build-essential.html
I don't know OpenSuse, but if it's anything like Debian, you can probably also install Ruby gems (and Perl and Python modules) directly from your package manager. This can be good and bad. Good because the package manager takes better care of dependencies and uninstalling (on average) than you would on your own. Bad because the distro will often have older versions than you might be able to get yourself. Still, it's an option to consider.
If using Windows and RubyInstaller.org, I believe you need to install the devkit they provide.
If you have make after checking with which make and you are sure you have ruby installed by checking which ruby it could be that you had installed something similar to sudo apt-get install ruby1.9.1-dev and then changed your mind and removed that because now you use rbenv or rvm or just installed from source. The problem is that the reference to /var/lib/ruby/1.9.1/ will still be associated with ruby gem and will try to install the gems there. Solution could be to remove that directory sudo rm -rf /var/lib/ruby/1.9.1/ and that could fix the issue.

Resources