Why is Spring causing permission issues with Ruby - ruby-on-rails

This is my first question on Stackoverflow thank you for reading it. Basically every time I start up my program which has Spring installed as a gem, no matter what command I run I get this error: Errno::EACCES Permission Denied. I have tried running commands with sudo and the same error appears. The only workaround I have found so far is to comment out Spring in the gem file and run bundle install again. Does anyone have any insight on why this might be happening and how to have spring running without this error appearing.

Related

Troubleshooting "Permission denied # rb_sysopen" when attempting to install an earlier version of Rails

Summarizing my problem
Details about my goal:
I want to install an older(stable) version of Rails; specifically 5.2.5.
Describing the expected and actual results:
I expect my Mac running Big Sur v11.3.1 (apple m1) to install Rails successfully.
The actual result is (presumably) a permission/ownership based error:
$ gem install rails -v 5.2.5
ERROR: While executing gem ... (Errno::EACCES)
Permission denied # rb_sysopen - /Users/ayylmao/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/concurrent-ruby-1.1.9/CHANGELOG.md
Obviously I see it's something to do with concurrent-ruby-1.1.9...though I continue to get this error with other gems throughout my efforts to install rails on this new-ish computer.
Describing what I've tried:
Both solutions here - no help
i've read this question - no help
I've read this question, but it's old
I've begun to explore my PATH:
/Users/ayylmao/.rbenv/shims:/Users/ayylmao/.rbenv/shims:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
and I've uninstalled previous installations of Rails (and railties), as well as removed rbenv and re-installed (via the usual for me, Homebrew)
I've run brew doctor, i've updated gems with gem update, i've gotten rid of seemingly superfluous gems with for i in gem list --no-versions; do gem uninstall -aIx $i; done.
Obviously, i'm at my wits end here...
My best guess
looking at my $PATH it seems super "sus"...looks like there's some redundancy...but I'm not certain how to troubleshoot it or if that's the correct place to be looking.
I've dropped most details about my system and environment throughout my question, but here's an agregate:
MacOS BigSur 11.3.1 (perhaps something to do with Apple's SIP?) smh
zsh
homebrew
rbenv
ruby 2.7.2
stating my question without any ambiguity
How do I troubleshoot this error "Permission denied # rb_sysopen" via closer inspection of my $PATH? And is that the most likely culprit?
What steps would I need to take to go completely "nuclear"?
PS - full disclosure...yes I have used sudo in some instance of installing rails...though i've quickly uninstalled those versions shortly after installation. I apologize for the irresponsibility. I was not prepared for the Apple SIP and panicked months ago....Also, ZSH was a change for me as well.
It seems like your ruby installation through rbenv was made via sudo, which will create gem structure with root privileges.
So, when you perform a gem install rails from a regular user, you won't have the privileges to write into gems directory, raising the permission denied error.
You can confirm the permission by running:
ls -la /Users/ayylmao/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/
Try to reinstall your ruby with you own user (without sudo) and the installation of rails or other gems will sould be fine.

How to fix "bundler: command not found: rails" when deploying using Google Cloud App Engine

I am trying to deploy my Rails app to Google Cloud using App Engine Flexible Environment. Everything works fine when I run gcloud app deploy, but at the very end, when App Engine tries to run my application using bundle exec rails server -p $PORT, as specified in my app.yaml file, it crashes and gives the following error message:
Error Response: [9] Application startup error: 'bundler: command not
found: rails Install missing gem executables with bundle install
I tried changing the entrypoint value, running bundle install again and again, and installing all my gem files locally, but none of that worked. I also tried installing rack and changing the endpoint to run the app using rackup command, but that didn't work either. I am also skipping my gemfile.lock in my app.yaml file due to a previous error that was solved on SO.
I think you'd also want to install bundler in your container instance.
gem install bundler
The reason I was getting this error is because I was skipping the Gemfile.lock due to a previous error that I thought was solved here. The aforementioned 'solution' led to this error. The solution that I found is to make some edits to Gemfile.lock that solved the issue instead of avoiding it. The edits can be seen here.

Rails Server Error - Fail after Gem Update

I was trying to make a contact form using this site
I made it to mount ContactForm then ran bundle update and bundle install. Now I am unable to start the rails server. I get this error:
Error: Command not recognized
Usage: rails COMMAND [ARGS]
I have used git to checkout my last working copy of the app but I still am unable to start the rails server and have tried searching for answers online, unsuccessfully. Please help. I do not know how to continue to work on my website.
Thank you.
No need to respond. I tried first updating my Gemfile to the specific versions I know I was using before the rails server failed to respond. I had no luck there. Then I just uninstalled every gem and reinstalled them all and was able to get it up and running again. Mystery to me, but solved.

Why can't I start my webserver (`rails server`)?

I've created a new rails app using rails composer (https://github.com/RailsApps/rails-composer). however when I start my rails server (WEBrick), I get the following error:
~/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/fileutils.rb:247:in `mkdir': Permission denied
I've looked at this question and tried the steps in the selected answer but I'm getting the same issue. This seems like a conflict between RVM and Bundler since I've got ruby-1.9.3 as the top level directory and 1.9.1 as an intermediate directory. Not really sure what that means.
Any help is greatly appreciated.
This is generally the result of some directory in your Rails directory not having the correct permissions.
Here is an in-depth discussion of the permissions in Rails: https://stackoverflow.com/a/6091058/1669208
If you wanted to check to see if that was the problem. Then on a NON-PRODUCTION SERVER give 777 access to the entire rails directory.

Cannot run rails commands due to possible error with .gemrc

When I type commands such as "rails server" or "rails console", I receive a large error message.
The error message
Failed to load /Users/user_name/.gemrc because it doesn't contain valid YAML hash
The trouble started when I ran these series of commands about an hour earlier.
sudo gem update --system
9934 gem install gemcutter
9935 gem tumble
9936 gem update --system
Based on my research I am speculating that this has something to do with my .gemrc file which is currently blank.
I am out of my depth and would appreciate any assistance.
Thank you
I resolved the issue.
I did some additional research in the rdoc and found a solution.
I was placing the YAML file in the wrong user.
Thank you ##Kashyap.
I now understand the difference between system and user installations.

Resources