0

Getting my local environment setup for Ruby on Rails.

So I have rails installed in my .rbenv file, and when I type which rails, that's confirmed.

where rails shows the /Users/<username>/.rbenv/shims folder where rails is multiple times, like 15 times currently, then one single entry for usr/bin/rails.

However, if you run rails --version, you get this:

Rails is not currently installed on this system. To get the latest version, simply type:

    $ sudo gem install rails

You can then rerun your "rails" command.

If you run gem install rails, you get this:

ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /Library/Ruby/Gems/2.6.0 directory.

But if you go back and run where rails again, you'll get even more entries for the /Users/<username>/.rbenv/shims directory, indicating that it's incrementing each time.

Tried to add an env variable my ~/.zshrc as per some guidance online, as so: export GEM_HOME="$HOME/.gem"

When I save and source it, I get a different error:

Building native extensions. This could take a while...
ERROR:  Error installing rails:
        ERROR: Failed to build gem native extension.

    current directory: /Users/<username>/.gem/gems/racc-1.7.3/ext/racc/cparse
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby -I /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0 -r ./siteconf20240118-44186-1bplyzo.rb extconf.rb
creating Makefile

current directory: /Users/<username>/.gem/gems/racc-1.7.3/ext/racc/cparse
make "DESTDIR=" clean

current directory: /Users/<username>/.gem/gems/racc-1.7.3/ext/racc/cparse
make "DESTDIR="
make: *** No rule to make target `/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/universal-darwin22/ruby/config.h', needed by `cparse.o'.  Stop.

make failed, exit code 2

Gem files will remain installed in /Users/<username>/.gem/gems/racc-1.7.3 for inspection.
Results logged to /Users/addie/.gem/extensions/universal-darwin-22/2.6.0/racc-1.7.3/gem_make.out

Anyone have any idea how to resolve this?

3
  • How did you install ruby? It seems like your whole setup might be broken. Commented Jan 18, 2024 at 21:16
  • Do you have the OS X command line tools installed? Commented Jan 18, 2024 at 21:16
  • Engineersmnsky i don't recall exactly how, i believe through brew? Beartech Not sure which ones you mean. How would I go about checking? Commented Jan 20, 2024 at 2:38

1 Answer 1

0

try sudo gem install rails and add your password, I faced this issue while trying gem install cocoapods

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.