gem install compass - Failed to build gem native extension, as shown below within Terminal:
johnlove% gem install compass
ERROR: Error installing compass:
ERROR: Failed to build gem native extension.
[THE BASICS]
[Macintosh:~] johnlove% which ruby
/usr/bin/ruby
[Macintosh:~] johnlove% which sass
/usr/local/bin/sass
[Macintosh:~] johnlove% which scss
/usr/local/bin/scss
[Macintosh:~] johnlove% which compass
compass: Command not found.
[MORE BASICS]
[Macintosh:~] johnlove% sass -v
Sass 3.5.5 (Bleeding Edge)
[Macintosh:~] johnlove% scss -v
Sass 3.5.5 (Bleeding Edge)
[Macintosh:~] johnlove% ruby -v
ruby 2.3.7p456 (2018-03-28 revision 63024) [universal.x86_64-darwin18]
[Macintosh:~] johnlove% compass -v
compass: Command not found.
[UPDATE 2]
did this in Terminal:
sudo gem install -n /usr/local/bin compass
GOT THIS BACK
current directory: /Library/Ruby/Gems/2.3.0/gems/ffi-1.9.21/ext/ffi_c
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby -I /Library/Ruby/Site/2.3.0 -r ./siteconf20190130-2612-nh9d7t.rb extconf.rb
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/universal-darwin18/rbconfig.rb:215: warning: Insecure world writable dir /usr/local/bin in PATH, mode 040757
checking for ffi.h... no
checking for ffi.h in /usr/local/include,/usr/include/ffi... no
checking for shlwapi.h... no
checking for rb_thread_blocking_region()... no
checking for rb_thread_call_with_gvl()... yes
checking for rb_thread_call_without_gvl()... yes
creating extconf.h
creating Makefile
current directory: /Library/Ruby/Gems/2.3.0/gems/ffi-1.9.21/ext/ffi_c
make "DESTDIR=" clean
current directory: /Library/Ruby/Gems/2.3.0/gems/ffi-1.9.21/ext/ffi_c
make "DESTDIR="
Running autoreconf for libffi
/Library/Ruby/Gems/2.3.0/gems/ffi-1.9.21/ext/ffi_c/libffi/autogen.sh: line 2: exec: autoreconf: not found
make: *** ["/Library/Ruby/Gems/2.3.0/gems/ffi-1.9.21/ext/ffi_c/libffi-universal-darwin18"/.libs/libffi_convenience.a] Error 127
make failed, exit code 2
end [UPDATE 2]
=====
[UPDATE 1]
I read that my PATHS may not be set up correctly, so I ran:
gem env
and got back:
RubyGems Environment:
- RUBYGEMS VERSION: 3.0.2
- RUBY VERSION: 2.3.7 (2018-03-28 patchlevel 456) [universal.x86_64-darwin18]
- INSTALLATION DIRECTORY: /Library/Ruby/Gems/2.3.0
- USER INSTALLATION DIRECTORY: /Users/johnlove/.gem/ruby/2.3.0
- RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby
- GIT EXECUTABLE: /usr/bin/git
- EXECUTABLE DIRECTORY: /usr/bin
- SPEC CACHE DIRECTORY: /Users/johnlove/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /Library/Ruby/Site
- RUBYGEMS PLATFORMS:
- ruby
- universal-darwin-18
- GEM PATHS:
- /Library/Ruby/Gems/2.3.0
- /Users/johnlove/.gem/ruby/2.3.0
- /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/gems/2.3.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /Library/Frameworks/Python.framework/Versions/Current/bin
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
What am I supposed to be looking for if my PATHS are messed up?
Another mystery?
sudo gem install compass
Got back?
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /usr/bin directory.
I tried to create a LOCAL usr/local/bin directory with full Read and Write permissions.
FAILED!
end [UPDATE 1]
=====
after getting the native extension error, I followed with
compass -v compass: Command not found.
I downloaded and installed the compass.app which now appears in the menubar. I have even created a Compass Project for one of my non-sass projects.
So, how does the Compass.app get successfully installed without the gem compass?
Tried his ...
sudo gem update --system
Got this back ...
Latest version already installed. Done.
Then, I tried this:
sudo apt-get install ruby-dev
Got this:
apt-get: command not found
I did do this:
xcode-select --install
got back:
command line tools are already installed
I guess I cannot blame it on Xcode.
Thanks in advance for saving my mind ...
The two main reasons for the errors in the original post are:
Trying to install compass using the system Ruby (the version of Ruby that comes preinstalled on a Mac).
Using sudo to install compass.
Learn why you shouldn't use the system Ruby to install gems on a Mac.
Learn why you should never use sudo to install gems.
Instead, you need to install a separate version of Ruby.
At a high level, setting up a proper Ruby development environment on a Mac involves six steps:
Install Homebrew (which also installs the prerequisite Apple command line tools)
Install a Ruby version manager (such as chruby, rbenv, asdf, RVM) - most of these can be installed with Homebrew
Configure the Ruby manager by adding the appropriate lines to your shell file (~/.bash_profile or ~/.zshrc) - each manager will have instructions for doing this, and this is a typical step that people miss
Restart the terminal (or open a new tab) for the shell changes to take effect - another step that is often overlooked
Install a specific version of Ruby using the Ruby manager
Switch to that version of Ruby using the Ruby manager
My personal preference is chruby with ruby-install. For more details and a script that can automate this whole process, check out my answer here:
https://stackoverflow.com/a/54873916/928191
I'm not sure, but did you install build-essential before try to install this gem? It's a commom issue for linux users
Try to install it before install this gem, for example:
sudo apt-get install build-essential
and then, install gem
sudo gem install compass
I made a simple test using docker and it only works when I install it, example:
Didn't work
docker run -it bash ubuntu:16.04 bash
apt-get update
apt-get install ruby2.3 ruby2.3-dev -y
gem install compass
It works
docker run -it bash ubuntu:16.04 bash
apt-get update
apt-get install build-essential ruby2.3 ruby2.3-devel
gem install compass
Why build-essentials?
The build-essentials package is a reference for all the packages needed to compile a Debian package. It generally includes the GCC/g++ compilers and libraries and some other utilities. Check the documentation: Here!
Related
I am trying to install Bundler on my VPS using Ansible.
I already have rbenv set up and the global ruby is 2.1.0.
If I SSH as root into the server and run gem install bundler, it installs perfectly.
I have tried the following three ways of using Ansible to install the Bundler gem and all three produce no errors, but when I SSH in and run gem list, Bundler is nowhere to be seen.
Attempt 1:
---
- name: Install Bundler
shell: gem install bundler
Attempt 2:
---
- name: Install Bundler
shell: gem install bundler
Attempt 3:
---
- name: Install Bundler
gem: name=bundler
state=latest
I have also tried the last attempt with user_install=yes and also with user_install=no and neither make any difference.
Any ideas how I can get it to install Bundler correctly via Ansible?
I've been working on this for a little while now and I have 1 ruby version installed: 2.1.0 and ahve found that the shims directory for rbenv does not contain a shim for bundle.
Should a shim for bundle be in there? I'm just getting confused as to why capistrano cannot find the bundle command as it's listed when I run sudo gem list but NOT when I run gem list?
root#weepingangel:/usr/local/rbenv/shims# echo $PATH
/usr/local/rbenv/shims:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
root#weepingangel:/usr/local/rbenv/shims# gem environment
RubyGems Environment:
- RUBYGEMS VERSION: 2.2.0
- RUBY VERSION: 2.1.0 (2013-12-25 patchlevel 0) [x86_64-linux]
- INSTALLATION DIRECTORY: /usr/local/rbenv/versions/2.1.0/lib/ruby/gems/2.1.0
- RUBY EXECUTABLE: /usr/local/rbenv/versions/2.1.0/bin/ruby
- EXECUTABLE DIRECTORY: /usr/local/rbenv/versions/2.1.0/bin
- SPEC CACHE DIRECTORY: /root/.gem/specs
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /usr/local/rbenv/versions/2.1.0/lib/ruby/gems/2.1.0
- /root/.gem/ruby/2.1.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- :sources => ["http://gems.rubyforge.org", "http://gems.github.com"]
- "gem" => "--no-ri --no-rdoc"
- REMOTE SOURCES:
- http://gems.rubyforge.org
- http://gems.github.com
- SHELL PATH:
- /usr/local/rbenv/versions/2.1.0/bin
- /usr/local/rbenv/libexec
- /usr/local/rbenv/shims
- /usr/local/sbin
- /usr/local/bin
- /usr/sbin
- /usr/bin
- /sbin
- /bin
- /usr/games
Any ideas?
So, I think the two main problems I have:
Why is bundler only visible when I run sudo gem list?
My deploy is saying:
INFO [18d5838c] Running /usr/bin/env bundle install --binstubs
/var/rails_apps/neiltonge/shared/bin --path
/var/rails_apps/neiltonge/shared/bundle --without development test
--deployment --quiet on 188.226.159.96 DEBUG [18d5838c] Command: cd /var/rails_apps/neiltonge/releases/20140301205432 && ( PATH=$PATH
/usr/bin/env bundle install --binstubs
/var/rails_apps/neiltonge/shared/bin --path
/var/rails_apps/neiltonge/shared/bundle --without development test
--deployment --quiet ) DEBUG [18d5838c] /usr/bin/env: bundle: No such file or directory
and this is my $PATH:
/usr/local/rbenv/shims:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
Why can't bundle be located?
The problem is that, when running gem install bundler via ansible, you're not initializing rbenv properly, since rbenv init is run in .bashrc or .bash_profile. So the gem command used is the system one, not the one installed as a rbenv shim. So whenever you install a gem, it is installed system-wide, not in your rbenv environment.
To have rbenv initialized properly, you must execute bash itself and explicitely state that it's a login shell, so it reads it's initialization files :
ansible your_host -m command -a 'bash -lc "gem install bundler"' -u your_rbenv_user
Leave the -u your_rbenv_user part if you really want to do this as root.
If the above command works, you can easily turn it into a playbook action :
- name: Install Bundler
become_user: your_rbenv_user
command: bash -lc "gem install bundler"
It's cumbersome, but it's the only way I found so far.
Since Ansible 1.3 following native solution is possible:
- name: requirements for installing gems
apt:
name: {{ item }}
with_items:
- ruby
- ruby-dev
- make
- name: install gem with proper $PATH
gem:
name: xyz
user_install: no
Mention the user_install parameter! Additionally some dependecies installed by the bundler could need following further package dependencies:
zlib1g-dev
I've met the similar environment issue when I tried to run commands as another user. As mentioned in this feature request you have two options to execute your command in login shell (that will load user environment). For example i'ld like to install bundler as rails user:
- name: Install Bundler
shell: gem install bundler
sudo_user: rails -i
or
- name: Install Bundler
command: sudo -iu rails gem install bundler
This Worked for me:
- name: rubygems | install bundler
shell: gem install bundler
- name: rbenv | rehash
shell: RBENV_ROOT={{ rbenv_root }} rbenv rehash
Sometimes after installing bundler, with rbenv on the system, you need to update your $PATH by runing rbenv rehash. I just tried the same thing with ansible, and it worked. Bundler is available in my $PATH after rehash.
The cleanest and quickest way to install bundler using Ansible is this:
Simply install rbenv by using the role https://github.com/zzet/ansible-rbenv-role and by configuring its plugins like so (obviously, there are more parameters to configure than just the plugins):
rbenv_plugins:
- { name: 'ruby-build',
repo: 'https://github.com/rbenv/ruby-build.git',
version: master }
- { name: 'rbenv-default-gems',
repo: 'https://github.com/rbenv/rbenv-default-gems.git',
version: master }
The included plugin rbenv-default-gems will add bundler by default and into the right directory during the installation process of the version of ruby you will have spcecified.
Then make sure bundler is in PATH.
That's it.
I got it working like this:
- name: Install jekyll and bundler
become_user: bob
gem:
name: "{{ item }}"
environment:
GEM_HOME: /home/bob/gems
PATH: $PATH:/bin/:/usr/bin/:/home/bob/gems/bin
with_items:
- jekyll
- bundler
Replace bob with your local user.
And then use the same principle with the bundler module
- name: Install Gems
become_user: bob
bundler:
gemfile: /home/bob/Gemfile
state: present
environment:
GEM_HOME: /home/bob/gems
PATH: $PATH:/bin/:/usr/bin/:/home/bob/gems/bin
my gem version is 1.3.5 and I can't install certain gems because of that.I tried to update the gem on my computer by
sudo update --system
and it gives me an error
ERROR: While executing gem ... (RuntimeError)
gem update --system is disabled on Debian.
RubyGems can be updated using the official
Debian repositories by aptitude or apt-get.
so according to some people, the source need to be downloads and it needs to executed by ruby. i downloaded the file, did
sudo ruby setup.rb
and it gave me
RubyGems 1.8.24 installed
== 1.8.24 / 2012-04-27
1 bug fix:
Install the .pem files properly. Fixes #320
Remove OpenSSL dependency from the http code path
RubyGems installed the following executables:
/usr/bin/gem1.8
but when I hit ruby gem -v it still gives me 1.3.5 rather than the one I installed which is 1.8.
Do I need to uninstall the older version manually? or some other thing I need to do first?
RubyGems installed the following executables: /usr/bin/gem1.8
As the line says, the name of the program is gem1.8, not gem. Ergo, you need to call
gem1.8 -v
not
gem -v
Please try make a symbolic link.
sudo ln -s /usr/bin/gem1.8 /usr/bin/gem
I've decided to move away from rvm to rbenv on my personal machine. Followed the rvm removal instructions, installed rbenv and everything looks peachy. After restarting my shell session:
$ rbenv global
1.9.3-p0
$ ls .rvm
ls: cannot access .rvm: No such file or directory
$ rbenv exec gem list
*** LOCAL GEMS ***
A completely fresh install in a fresh shell--RVM's long gone. Now, when I install bundler
$ rbenv exec gem install bundler
Fetching: bundler-1.0.22.gem (100%)
Successfully installed bundler-1.0.22
1 gem installed
$ rbenv rehash
$ echo $?
0
$ rbenv which bundle
rbenv: bundle: command not found
What? Indeed, look at this nonsense:
$ ls .rvm/gems/ruby-1.9.3-p0/gems/bundler-1.0.22/
bin bundler.gemspec CHANGELOG.md ISSUES.md lib LICENSE man Rakefile README.md spec UPGRADING.md
Somehow, someway, RVM still has its hooks into me. My ~/.bash* files are clean and
$ cat ~/.gemrc
gem: --no-ri --no-rdoc
I have no system ruby, no globally installed RVM (nothing in /etc/profile/, no /etc/profile.d/rvm.sh and nothing in /etc/bash.bashrc) and I'm at a complete loss.
$ gem env
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.11
- RUBY VERSION: 1.9.3 (2011-10-30 patchlevel 0) [i686-linux]
- INSTALLATION DIRECTORY: /home/blt/.rvm/gems/ruby-1.9.3-p0
- RUBY EXECUTABLE: /home/blt/.rbenv/versions/1.9.3-p0/bin/ruby
- EXECUTABLE DIRECTORY: /home/blt/.rvm/gems/ruby-1.9.3-p0/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-linux
- GEM PATHS:
- /home/blt/.rvm/gems/ruby-1.9.3-p0
- /home/blt/.rvm/gems/ruby-1.9.3-p0#global
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- "gem" => "--no-ri --no-rdoc"
- REMOTE SOURCES:
- http://rubygems.org/
Where else can I look to figure out why gem's configured to install to ~/.rvm?
Something's clearly rotten on my system; no grepping has turned it up, but tacking
unset GEM_HOME
unset GEM_PATH
to the end of my ~/.bashrc made things sane. Horrible hack, though.
Have you ever installed rvm in a system location? Maybe those env vars got into a system-wide shell config.
Try running:
bash -l -x -c 'echo'
This will print bash debugging output so you can see what files are being loaded. It may not show commands inside sourced scripts, depending on your version of bash.
This probably doesn't apply to you, but if it exists, what are the contents of ~/.gemrc ?
I was following the instructions here, so I ran gem install jekyll on my osx machine, and got the following:
WARNING: Installing to ~/.gem since /Library/Ruby/Gems/1.8 and
/usr/bin aren't both writable.
WARNING: You don't have /Users/erikvold/.gem/ruby/1.8/bin in your PATH,
gem executables will not run.
ERROR: Error installing jekyll:
liquid requires RubyGems version >= 1.3.7
But I don't see instructions on how to deal with this in the instructions above.
Try to update gem first:
$ gem update --system
In case you get permission errors, you must resort to sudo for this and all other gem commands:
$ sudo gem update --system
I'm running Ubuntu 10.04 and originally installed ruby 1.9.1 (from source). I've just decided to try out ruby 1.9.2 and rails 3, and it seemed like a good time to use rvm to deal with the multiple ruby installs and gemsets.
rvm installed and seems to be working, I installed ruby 1.9.2 in rvm and made that my default ruby. However, every time I try to install a gem under ruby 1.9.2 I see this error.
mark#Steve-Austins-Penguin:~$ gem install haml
ERROR: While executing gem ... (Errno::EACCES)
Permission denied - /home/mark/.gem/specs
gem environment returns:
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.7
- RUBY VERSION: 1.9.2 (2010-08-18 patchlevel 0) [x86_64-linux]
- INSTALLATION DIRECTORY: /home/mark/.rvm/gems/ruby-1.9.2-p0
- RUBY EXECUTABLE: /home/mark/.rvm/rubies/ruby-1.9.2-p0/bin/ruby
- EXECUTABLE DIRECTORY: /home/mark/.rvm/gems/ruby-1.9.2-p0/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /home/mark/.rvm/gems/ruby-1.9.2-p0
- /home/mark/.rvm/gems/ruby-1.9.2-p0#global
<snip>
But if the correct installation, ruby and gem paths are showing here why is ruby trying to install gems to /home/mark/.gem? All the variables and paths shown by env look right, and I can't find a .gemrc file anywhere on my system that might contain conflicting path settings.
So I guess my question is what might be causing rubygems to attempt to install to /home/mark/.gems instead of the correct paths set by rvm?
In response to the question below:
mark#Steve-Austins-Penguin:~$ echo $PATH
/home/mark/.rvm/gems/ruby-1.9.2-p0/bin:/home/mark/.rvm/gems/ruby-1.9.2-p0#global/bin:/home/mark/.rvm/rubies/ruby-1.9.2-p0/bin:/home/mark/.rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
mark#Steve-Austins-Penguin:~$ which gem
/home/mark/.rvm/rubies/ruby-1.9.2-p0/bin/gem
mark#Steve-Austins-Penguin:~$ rvm list
rvm rubies
ruby-1.8.7-p302 [ x86_64 ]
=> ruby-1.9.2-p0 [ x86_64 ]
mark#Steve-Austins-Penguin:~$ env
rvm_gemsets_path=/home/mark/.rvm/gemsets
MANPATH=:/home/mark/.rvm/man
rvm_scripts_path=/home/mark/.rvm/scripts
rvm_bin_path=/home/mark/.rvm/bin
GEM_HOME=/home/mark/.rvm/gems/ruby-1.9.2-p0
rvm_patchsets_path=/home/mark/.rvm/patchsets
SHELL=/bin/bash
IRBRC=/home/mark/.rvm/rubies/ruby-1.9.2-p0/.irbrc
rvm_patches_path=/home/mark/.rvm/patches
MY_RUBY_HOME=/home/mark/.rvm/rubies/ruby-1.9.2-p0
rvm_selfcontained=1
USER=mark
__shell_array_start=0
rvm_gems_cache_path=/home/mark/.rvm/gems/cache
rvm_config_path=/home/mark/.rvm/config
rvm_path=/home/mark/.rvm
USERNAME=mark
rvm_gemset_separator=#
rvm_ruby_args=
rvm_rubies_path=/home/mark/.rvm/rubies
PWD=/home/mark
rvm_hooks_path=/home/mark/.rvm/hooks
rvm_version=1.0.1
rvm_src_path=/home/mark/.rvm/src
HOME=/home/mark
rvm_gems_path=/home/mark/.rvm/gems
rvm_ruby_string=ruby-1.9.2-p0
BUNDLE_PATH=/home/mark/.rvm/gems/ruby-1.9.2-p0
rvm_tmp_path=/home/mark/.rvm/tmp
LOGNAME=mark
GEM_PATH=/home/mark/.rvm/gems/ruby-1.9.2-p0:/home/mark/.rvm/gems/ruby-1.9.2-p0#global
rvm_action=list
rvm_log_path=/home/mark/.rvm/log
rvm_interactive=1
RUBY_VERSION=ruby-1.9.2-p0
rvm_archives_path=/home/mark/.rvm/archives
rvm_repo_path=/home/mark/.rvm/repos
_=/usr/bin/env
Note that I've edited down the response from env slightly - simply to keep the size of this post under control - by removing all the entries relating to X, GNOME and SSH.
Following up the backtrace from running gem install -V --backtrace --debug haml (thanks zzzhc) and taking a closer look at the /home/mark/.gem directory I found that there were no gems installed there, just gemspec files and gem source files. In the spirit of experimentation I deleted /home/mark/.gem and re ran the gem install command and suddenly it was working. And that it had recreated /home/mark/.gem containing gemspecs for the gems I'd just installed.
It's clear now that I'd misinterpreted the error message in the original question; rubygems didn't fail while trying to install gems to /home/mark/.gem, it was simply using that directory as a temporary store for the gemspecs of newly downloaded gems about to be installed. Before installing rvm I'd been installing gems onto the system using sudo gem install... which would have created the /home/mark/.gem directory with root permissions. So rubygems run without sudo was unable to access the temp directory to store gemspecs in and was aborting before it could install the gems. Doh!
Another way is type which gem after getting into the ruby version. You will get something like this - /home/username/.rvm/rubies/ruby-1.9.2-p180/bin/gem. Now just type sudo /home/username/.rvm/rubies/ruby-1.9.2-p180/bin/gem install gem_name.
Specifying the complete path and adding sudo work fine.
check the first line of /home/mark/.rvm/rubies/ruby-1.9.2-p0/bin/gem and look at http://yehudakatz.com/2010/08/24/a-tale-of-abort-traps-or-always-question-your-assumptions/