You dont have a write permission for gems on ROR - ruby-on-rails

[enter image description here](https://i.stack.imgur.com/Y02fm.png)enter image description here
Hello
I am getting issue on ubuntu machine while installing bundler(screenshot attached) for ROR application my current ubuntu OS version is 22.04.
I tried to downgrade the bundler version but, it's not working.
Its showing I don't have write permission for gem folder.
Is that OS issue or if my make any mistake while installing.
Can you anyone help me to resolve this issue.
Thanks
can you please help whether this one ubuntu 22.04 OS issue or gems issue

The error is because your project requires (either in the Gemfile or required by a different gem) a google-api-client version (the error says google-api-client >= 0.9.5, < 0.33.0) with a dependency on Ruby 2.x. You're running Ruby 3 so bundler is complaining.
You either need to downgrade Ruby, or upgrade the gem (better). In this commit on the google-api-client repo you can see the point where the gem was changed to allow Ruby 3+. From the list of tags listed at the top of the page, it looks like you need to make sure your project requires google-api-client v0.44.2 or greater.

Related

I encountered a "You don't have write permissions" error when installing an older version of Rails

I have read the related answers, but the content is too complicated and I am not sure how to do it.
Since I inherited an old project, I need to use Ruby version 2.3.1, I cannot install the latest version of Ruby, nor can I install the latest version of Rails (must match the Ruby version).
I installed Rails under the following instructions on the MacOS terminal:
gem install rails -v 4.2.2
But after a few lines of messages, an error message appears as follows
While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.6.0 directory.
I'm not sure if I chose the wrong version of Rails, or there are other operational errors. Please tell me what should I do?
I just moved from Windows to MacOS.
I added "--user-install" at the end of the original instruction to proceed to the next step:
gem install rails -v 4.2.2 --user-install

Upgrading rails on Mac

I know the question to this is probably very straight forward, but Im a bit new to rails, so please bear with me. I have had rails version 5.1.5 on my Mac and I need to update rails to version 5.1.6 and I'm not able for the life of me to do that.
I tried
`sudo gem install rails -v 5.1.6`
but this gives the error
ERROR: Failed to build gem native extension.
Using gem list gives that I have
rails (5.1.5, 5.1.4)
I also tried bundle update rails
I keep getting Could not locate Gemfile
What am I doing wrong??
gem is the native package manager for Ruby.
Bundler (bundle) is a gem to manage bundles of gems via a Gemfile.
I recommend you use a version manager for Ruby like rvm, rbenv or chruby and also install xcode and the commandline-tools package of xcode. Some gems have dependencies written in C that need to be configured and compiled, all of that and some more comes with xcode.

Do I have to install Ruby from source to get Ruby 2.2.0 and Rails 4.2.0 installed on my windows machine?

I currently have Ruby 2.2.6 and Rails 5.0.1 installed on my Windows 10 machine. I have cloned an existing project that has the following settings included in its Gemfile:
# Lock-in Lang and Framework:
ruby '2.2.0'
gem 'rails', '4.2.0'
I'm having a surprisingly hard time figuring out how to get Ruby 2.2.0 and Rails 4.2.0 installed. Ruby has good documentation of different installation options, but I think I've exhausted the Windows options without any success. Here are a couple I tried:
Installers: I couldn't find an option for downloading either from RailsInstaller, RubyInstaller, and Bitnami.
RVM: I tried (unsuccessfully) following this blog post to install cygwin so that I could use RVM, but then saw in the comments that the author now recommends spinning up a linux VM rather that using this method.
Pik and Uru: It appears Pik is no longer maintained, and I couldn't figure how to download new versions and ruby and rails with Uru as opposed to managing already downloaded versions.
EDIT: I also tried simply changing the version numbers for ruby and rails in the Gemfile to 2.2.6 and 5.0.1. When I do this I (very understandably) get a message when I try to use a rails command saying I need to run bundle update rails. When I run that rails update I get the following error: Bundler could not find compatible versions for gem "rack". I've done some googling on that option, and it looks like resolving that issue might be possible but requires some more involved tinkering with my Gemfile configuration.
I think my next option is to install Ruby from the source, but I wanted to throw a question up here first to make sure I'm not missing an easier method. So my question is - is it really this hard to get an older minor release of ruby and rails installed on Windows? I realize that the majority of users are probably looking for the most recent release, but it doesn't seem to me that my use case is terribly unique.
The oldest available Ruby 2.2.x via RubyInstaller is 2.2.1
So, the answer to your question is, "Yes, you'll have to build from source."
But then again,
v2.x of gem "rack" requires at least Ruby v2.2.2
And depending on what other gems are included in your Gemfile, you'll still have to reconfigure your Gemfile to get this app running.
So the best solution is probably to use the latest patch version of Ruby 2.2.x and lock rails to 4.2.x. (The app may not be compatible with Rails 5.x)
# Lock-in Lang and Framework:
ruby '2.2.6'
gem 'rails', '~> 4.2'
Then run bundle install to install all the gems required by the Gemfile

Ruby on Rails on Windows 'SQLite' installing error

I am facing this problem any one can help me. Ruby version 2.0.0 and rails version 4.2.1.
And run this Command also.
'gem install sqlite3 --platform=ruby -- --with-sqlite3-include=c:/sqlite/include --with-sqlite3-lib=c:/sqlite/lib'.
Developing Ruby in Windows will create many problems, as many gems won't even work. I'd suggest rethinking OS choice.
In your case it seem like you haven't installed SQLite (the app, not the gem). You can find it here: https://www.sqlite.org/download.html

Gem compatibility in rails 2.3.4

I have currently moved to a appplication on rails 2.3.4 and ruby 1.8.7 using rvm.
There are a no of gems installed in the app.When i do gem install gem_name ,it installs it but iam not sure whether the gem version is compatible with my app.The gem versions are not specified in case of many gems listed config/environment.rb.Iam unable to figure out ,how to install the correct version as unable to run the application till now. Any suggestions are welcome..
To provide true gem-consistency in your app, you should consider use Bundler to manage these dependencies. The Gembundler site has a good guide on setup for rails 2.x apps.
Once you have your dependencies in bundler, you can start to work out what is compatible and what isn't. In the case of third-party gems, you can search for them on the RubyGems site, and work out which version was the last to be released before Rails 3.x was released. Of course most gems will just work, but any breaking gems will possibly need to run an older version.
I would use Bundler, and add the gems to the Gemfile. Here is the syntax to use a specific version:
gem 'gem-name', '1.0.4'

Resources