Search code examples
ruby-on-railsmacospermissionsbundlerrbenv

Trying to create a rails app but keeps failing to setup


I'm trying to create my first rails app. I'm on a Macbook Pro, so macOS. I've been following this guide setting up rbenv, rails etc. https://www.digitalocean.com/community/tutorials/how-to-install-ruby-on-rails-with-rbenv-on-macos Then I'm following a crash course on YouTube. In the terminal I try to create a new rails app

rails new foodlog

It starts to set up in the folder I made for it, but the following happens during setup

Bundler::PermissionError: There was an error whle trying to create 
'/Users/myusername/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/extensions/arm64-darwin-21/2.7.0/racc-1.6.0'. 
It is likely that you need to grand executable permissions for all parent directories and write permissions for
/Users/myusername/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/extensions/arm64-darwin-21/2.7.0'

This error continues repeating the same thing with things such as "strscan". Then after it says

In gemfile:
rails was resolved to 7.0.3.1, which depends on
actionmailbox was resolved to 7.0.3.1, which depends on
net-imp was resolved to 0.2.3, which depends on
stscan
run bundle binstubs bundler
Could not find gem 'sprockets-rails' in locally installed gems.
rails importmap:install
Could not find gem 'sprockets-rails' in locally installed gems.
Run 'bundle install' to install missing gems.
rails turbo:install stimulus:install
Could not find gem 'sprockets-rails' in locally installed gems.
Run 'bundle install' to install missing gems

I've tried looking online, coming across similar but not exact issues. For example, one solution suggested doing bundle install in this directory, versus where the guide says do it in the home directory. So I do that and get

Bundle complete! 0 gemfile dependencies, 1 gem now installed.

Still doesn't do anything. I think the main culprit is the permissions error it mentions above? This is my first time trying to really do any development on the macOS and I'm sure there's just a misunderstanding somewhere regarding permissions, so if anyone can help that would be appreciated!


Solution

  • It is likely that you need to grand executable permissions for all parent directories and write permissions for /Users/myusername/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/extensions/arm64-darwin-21/2.7.0'

    Your question does not mention, so I think you might have missed this suggestion. Make sure all directories have the executable permission