I wanted to install ruby on rails for windows 10, following the same instructions of this video: https://www.youtube.com/watch?v=G-B_KUFNkQQ
When it finish the installation of ruby, I return to the console and after gem install rails, I get this error:
C:\Users\Usuario>gem install rails --no-document
Temporarily enhancing PATH for MSYS/MINGW...
Building native extensions. This could take a while...
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
current directory: C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/mimemagic-0.3.9/ext/mimemagic
C:/Ruby27-x64/bin/ruby.exe -IC:/Ruby27-x64/lib/ruby/2.7.0/rubygems -rrubygems C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rake-13.0.1/exe/rake RUBYARCHDIR\=C:/Ruby27-x64/lib/ruby/gems/2.7.0/extensions/x64-mingw32/2.7.0/mimemagic-0.3.9 RUBYLIBDIR\=C:/Ruby27-x64/lib/ruby/gems/2.7.0/extensions/x64-mingw32/2.7.0/mimemagic-0.3.9
rake aborted!
Could not find MIME type database in the following locations: ["/usr/local/share/mime/packages/freedesktop.org.xml", "/opt/homebrew/share/mime/packages/freedesktop.org.xml", "/usr/share/mime/packages/freedesktop.org.xml"]
Ensure you have either installed the shared-mime-info package for your distribution, or
obtain a version of freedesktop.org.xml and set FREEDESKTOP_MIME_TYPES_PATH to the location
of that file.
Tasks: TOP => default
(See full trace by running task with --trace)
rake failed, exit code 1
Gem files will remain installed in C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/mimemagic-0.3.9 for inspection.
Results logged to C:/Ruby27-x64/lib/ruby/gems/2.7.0/extensions/x64-mingw32/2.7.0/mimemagic-0.3.9/gem_make.out
I tried to solve making an update and "gem install mime-types-data" but stills with the same problem...
The Ruby Installer is Ruby+Devkit 2.7.2-1 (x64) and my ruby version is ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x64-mingw32]
Windows 10 ruby 2.6.2 install rails 6.0.0.rc1
Download the shared-mime-info from https://gitlab.freedesktop.org/xdg/shared-mime-info/uploads/0440063a2e6823a4b1a6fb2f2af8350f/shared-mime-info-2.0.tar.xz
Extract the downloaded package with 7Zip or WinRAR.
Place it in a location of your choice e.g. "C:\package".
Set a new Environment Variable with a name: FREEDESKTOP_MIME_TYPES_PATH and
browse value to the location e.g. C:\shared-mime-info 2.0\data\freedesktop.org.xml.in
Refresh terminal or CMD e.g. Command
refreshenv
And finally, gem install rails -v 6.0.0.rc1
windows 10
ruby : 2.5.8
I downloaded package from https://gitlab.freedesktop.org/xdg/shared-mime-info/ and then set the environment variable (Windows) FREEDESKTOP_MIME_TYPES_PATH to that path ("c:....\data\freedesktop.org.xml.in")
also I installed mime-types-data > gem install mime-types-data
at first it didn't work after closing and opening again the terminal it did.
tip: if you use vscode you need to reopen vscode
Mac
If you are using macOS, try the following
brew install shared-mime-info
bundle update mimemagic
the problem is that the mimemagic team yanked a lot of versions yesterday https://rubygems.org/gems/mimemagic/versions
now you have to install the package shared-mime-info in your distribution.
I would recommend using WSL for rails development in windows, it will save a lot of problems in the future.
after a quick google search, this seems appropriate:
from MimeMagic Github Page :
This process will also work on a Windows machine.
Download the package from
https://packages.debian.org/sid/amd64/shared-mime-info/download
Ensure the command line version of 7-Zip is installed
7z x -so shared-mime-info_2.0-1_amd64.deb data.tar | 7z e -sidata.tar "./usr/share/mime/packages/freedesktop.org.xml"
Place the file
freedesktop.org.xml in an appropriate location, and then set the
environment variable FREEDESKTOP_MIME_TYPES_PATH to that path.
Once that has been done the gem should install successfully.
Please note
that the gem will depend upon the file remaining in that location at
run time.
For MacOs or Linux - Install shared-mime-info package to resolve that issue.
macOS
$ brew install shared-mime-info
Debian, Ubuntu
apt-get update && apt-get install -y shared-mime-info
Related
I've had some issues starting a new RAILS project, where I'm getting an error that there is a missing file /usr/local/share/mime/packages/freedesktop.org.xml. There was a connection with the mimemagic dependencies, and I found this issue on GitHub about the mimemagic version and licensing - https://github.com/rails/rails/issues/41750
Wondering if anybody else ran into the issue, and could explain what is going on.
I'm using rbenv with ruby version: 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-darwin19], and rails 6.1.3
Here is the error message in the command line:
Installing railties 6.1.3
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /Users/nico/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/mimemagic-0.3.7/ext/mimemagic
/Users/nico/.rbenv/versions/3.0.0/bin/ruby -I/Users/nico/.rbenv/versions/3.0.0/lib/ruby/3.0.0 -rrubygems
/Users/nico/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rake-13.0.3/exe/rake
RUBYARCHDIR\=/Users/nico/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/extensions/x86_64-darwin-19/3.0.0/mimemagic-0.3.7
RUBYLIBDIR\=/Users/nico/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/extensions/x86_64-darwin-19/3.0.0/mimemagic-0.3.7
rake aborted!
Could not find MIME type database in the following locations: ["/usr/local/share/mime/packages/freedesktop.org.xml",
"/opt/homebrew/share/mime/packages/freedesktop.org.xml", "/usr/share/mime/packages/freedesktop.org.xml"]
Ensure you have either installed the shared-mime-types package for your distribution, or
obtain a version of freedesktop.org.xml and set FREEDESKTOP_MIME_TYPES_PATH to the location of that file.
Tasks: TOP => default
(See full trace by running task with --trace)
rake failed, exit code 1
Thanks,
Nico
Found some links to shared-mime-info on the GitHub link I posted, and I solved the issue by running the command below and starting a new project:
brew install shared-mime-info
If you are on ubuntu OS you can run below command
sudo apt-get install shared-mime-info
If migrating data from an Intel Mac (or an M1 Mac running Rosetta 2) to an M1, note that mimemagic will cache the old directory, so in addition to brew install shared-mime-info, you'll want to run:
gem uninstall mimemagic
gem install mimemagic
When I try to start my Rails server, I get the following error:
$ bundle exec rails s
Your Ruby version is 2.3.7, but your Gemfile specified ~> 2.3.8
I don't understand why that happens though, since I set Ruby to 2.3.8 both using Homebrew and using rbenv. 2.3.7 is the version of the system's ruby. I am using Mac OS 10.14.4.
$ ruby -v
ruby 2.3.8p459 (2018-10-18 revision 65136) [x86_64-darwin18]
$ rbenv version
2.3.8 (set by /Users/ceasar/foo/.ruby-version)
$ which -a ruby
/Users/ceasar/.rbenv/shims/ruby
/usr/local/opt/ruby#2.3/bin/ruby
/usr/local/bin/ruby
/usr/bin/ruby
$ which -a bundle
/Users/ceasar/.rbenv/shims/bundle
/usr/local/bin/bundle
$ /usr/bin/xcodebuild -version
Xcode 10.2
Build version 10E125
$ brew list ruby#2.3
/usr/local/Cellar/ruby#2.3/2.3.8_1/bin/erb
/usr/local/Cellar/ruby#2.3/2.3.8_1/bin/gem
/usr/local/Cellar/ruby#2.3/2.3.8_1/bin/irb
/usr/local/Cellar/ruby#2.3/2.3.8_1/bin/rake
/usr/local/Cellar/ruby#2.3/2.3.8_1/bin/rdoc
/usr/local/Cellar/ruby#2.3/2.3.8_1/bin/ri
/usr/local/Cellar/ruby#2.3/2.3.8_1/bin/ruby
/usr/local/Cellar/ruby#2.3/2.3.8_1/include/ruby-2.3.0/ (25 files)
/usr/local/Cellar/ruby#2.3/2.3.8_1/lib/libruby.2.3.0.dylib
/usr/local/Cellar/ruby#2.3/2.3.8_1/lib/pkgconfig/ruby-2.3.pc
/usr/local/Cellar/ruby#2.3/2.3.8_1/lib/ruby/ (1211 files)
/usr/local/Cellar/ruby#2.3/2.3.8_1/lib/ (3 other files)
/usr/local/Cellar/ruby#2.3/2.3.8_1/share/emacs/ (7 files)
/usr/local/Cellar/ruby#2.3/2.3.8_1/share/man/ (4 files)
/usr/local/Cellar/ruby#2.3/2.3.8_1/share/ri/ (13487 files
$ bundle env | head -n 40
## Environment
```
Bundler 2.0.1
Platforms ruby, x86_64-darwin-18
Ruby 2.3.8p459 (2018-10-18 revision 65136) [x86_64-darwin18]
Full Path /Users/ceasar/.rbenv/versions/2.3.8/bin/ruby
Config Dir /Users/ceasar/.rbenv/versions/2.3.8/etc
RubyGems 2.5.2.3
Gem Home /Users/ceasar/.rbenv/versions/2.3.8/lib/ruby/gems/2.3.0
Gem Path /Users/ceasar/.gem/ruby/2.3.0:/Users/ceasar/.rbenv/versions/2.3.8/lib/ruby/gems/2.3.0
User Path /Users/ceasar/.gem/ruby/2.3.0
Bin Dir /Users/ceasar/.rbenv/versions/2.3.8/bin
Tools
Git 2.19.2
RVM not installed
rbenv rbenv 1.1.2
chruby not installed
```
## Bundler Build Metadata
```
Built At 2019-01-04
Git SHA d7ad2192f
Released Version true
```
## Bundler settings
```
build.libv8
Set for the current user (/Users/ceasar/.bundle/config): "--with-system-v8"
build.mysql2
Set for the current user (/Users/ceasar/.bundle/config): "--with-mysql-config=/usr/local/Cellar/mysql#5.7/5.7.24/bin/mysql_config"
path
Set for your local app (/Users/ceasar/Desktop/beacon/.bundle/config): "vendor/bundle"
disable_shared_gems
Set for your local app (/Users/ceasar/Desktop/beacon/.bundle/config): true
```
I don't see anything here which would make me think it shouuld be using 2.3.7.
I'm not sure what else to try.
How does Bundler decide which version of Ruby to use, and how can I configure it to use either rbenv or my homebrew Ruby installation?
How about to try to use 'rvm'?
rvm install 2.4.2
This command will install another version of ruby, 2.4.2
And you can simply check the versions which all you have as
rvm list.
After this, run the version which you wish as the below,
rvm <version> or rvm use <version>
Hope this will help you!
Summary: The wrong version of bundler causes the problem. Use a ruby version manager to install the needed ruby version. Then install the correct version of the bundler gem for your project.
Details: In my case I'm running a rails example on github that required an older version of ruby and bundler and got the error described.
To manage my different ruby versions, I'm using ruby-install and chruby both installed with homebrew.
I followed these steps to resolve the problem on macOS Catalina v10.15.7:
Resolution steps
% ruby-install 2.4.1
# open a new shell so chruby will find 2.4.1
% chruby 2.4.1
% which ruby
/Users/richardlogwood/.rubies/ruby-2.4.1/bin/ruby
% gem install bundler:1.16.1
% which bundle
/Users/richardlogwood/.gem/ruby/2.4.1/bin/bundle
% cd (to the rails project directory)
# Note: it's a rails project so there was a binstub
# for bundler, hence `bin/bundler` in the project directory*
% bin/bundler install
% rake db:{create,migrate}
% bin/rails s
Before running the above steps, the error messages told me which version of ruby and bundler I needed to install. The system bundler was the wrong version (I'm on a mac) and the initial error message using that version gave me the error below. Only after installing the needed bundler gem (see above) was the correct ruby version resolved (see above).
Errors before resolution
% bundle install
Your Ruby version is 2.6.3, but your Gemfile specified 2.4.1
% which ruby
/Users/richardlogwood/.rubies/ruby-2.4.1/bin/ruby
% which bundle
/usr/bin/bundle
Note, the required bundler version was indicated by this error message:
Could not find 'bundler' (1.16.1) required by your ... /Gemfile.lock. (Gem::GemNotFoundException)
To update to the latest version installed on your system, run `bundle update --bundler`.
To install the missing version, run `gem install bundler:1.16.1`
I don't suggest using RVM instead of RBEnv. RBEnv is one of the most up-to-date solutions around, and most people stick with it.
Can you please try running gem update --system to update your bundler first.
Install Rbenv and run the following commands in your project directory to install 2.3.8:
rbenv install 2.3.8
rbenv local 2.3.8
bundle install --path=vendor/cache
I had rbenv installed and also installed Ruby manually at some point because of certain issues which I thought I cleaned up. But it seems I had /usr/local/bin/{bundle,bundler} still present which was evident when I did: which bundle that showed it's location not under shims (belonging to rbenv) so I simply had to remove these e.g. rm -rf /usr/local/bin/{bundle,bundler} and all was working again.
I have a friend's website code, which is in Ruby on Rails.
I have tried to install RoR on my Mac using instructions at gorails.com
OS : Mac Mojave
ruby -v : ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-darwin18]
rails -v :
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/rubygems.rb:241:in `bin_path': can't find gem railties (>= 0.a) (Gem::GemNotFoundException)
from /usr/local/bin/rails:22:in `<main>'
What I tried : I installed ruby, and then rails, using gorails tutorial, and kept getting errors stating version number mismatch.
Keep in mind that creating a new app, worked, but trying to run this existing code is a problem.
So then I uninstalled everything and updated the version using rvm, and since then I am getting this error.
When I cd into the webapp folder and run bundle install, I get errors, such as:
zsh: /Users/abc/.rvm/gems/ruby-2.2.3#hs/bin/bundle: bad interpreter: /Users/abc/.rbenv/versions/2.5.3/bin/ruby: no such file or directory
Could not load OpenSSL.
You must recompile Ruby with OpenSSL support or change the sources in your
Gemfile from 'https' to 'http'. Instructions for compiling with OpenSSL using
RVM are available at rvm.io/packages/openssl.
This project uses a PostgreSQL database, which I have setup already.
If required, I can share the gemfile of this project too.
What is the best way to get this project working?
Am I missing something crucial?
You can't run RVM and RBENV on the same machine. Pick one and remove the other. You're probably best to uninstall both and then pick one, start over.
Uninstall RBENV instructions here or in your case probably brew uninstall rbenv
Uninstall RVM see How can I remove RVM (Ruby Version Manager) from my system?
Close all terminals and then start a new one.
Install RVM see https://rvm.io/rvm/install
Then go to your project, make sure you have the correct ruby version needed by your project. If not, you will need to install with rvm install 2.5.1 for example.
Then run
rvm use 2.5.1 #or some other version
Then you should be able to run bundle install
The rest of the instructions in your link should be ok.
I am trying to update ruby gems by using:
gem update --system
But I am getting error:
ERROR: While executing gem ...(Gem::RemoteFetcher::UnknownHostError)
no such name (https://rubygems.org/specs.4.8.gz).
Unsure what version of rubygems you have installed, however there are three ways to fix:
network issues - try again later.
the version you have is bricked for updates, and you will need to install another way
NOTE: RubyGems 1.1 and 1.2 have problems upgrading when there is no rubygems-update installed. You will need to use the following instructions if you see Nothing to update. If you have an older version of RubyGems installed, then you can still do it in two steps:
$ gem install rubygems-update # might need to be admin/root
$ update_rubygems
Failing that you have to get your hands dirty:
Download from https://rubygems.org/pages/download
Unpack into a directory and cd there
Install with: ruby setup.rb (you may need admin/root privilege)
See https://rubygems.org/pages/download for more info
I'm trying to install the Gemfile contents using Bundle install but getting the error
rbenv: version `2.0.0' is not installed
The version of ruby installed in my system is:
ruby 2.1.2p95 (2014-05-08 revision 45877) [i686-linux]
and rbenv
2.1.2 (set by /home/jay/.rbenv/version)
2.1.3
The Gemfile requires ruby "2.0.0". Can any one tell how to install the required version without affecting the existing ones.
You can find a lot of information here: rbenv on github
To list all available installation candidates:
rbenv install -l
To install a ruby version you need (for example):
rbenv install 2.0.0-p643
So that you will only use this ruby version in this specific folder and not affect anything else you can do:
rbenv local 2.0.0-p643
This will generate a .ruby-version file in that directory which will force rbenv to use this ruby version here.
Just run:
rbenv install 2.0.0-p643
Which is the lastest 2.0.0 version.
If that version is not available on your system, run ruby-build --definitions to pick the lastest known 2.0.0 version on your system.
For me, I just ran
gem install bundler
and then run
bundle install
worked like a charm
You must change the ruby's version in .ruby-version file and in Gemfile
If you are getting a build failed error when trying to run rbenv install 2.0.0-p643 and after waiting for a few minutes; you might also see the last 10 lines of a log file as an output.
This can give you the hint of what would have happened for the build failure. It might miss some required library/dependency needed to be installed.
For ex. I got the following error for build failure-
ERROR: Ruby install aborted due to missing extensions
Try running `apt-get install -y libreadline-dev` to fetch missing dependencies.