Error Installing Jekyll on Mac OS Mavericks (10.9.2) - ruby

Trying to install stable version of Jekyll on OSX Mavericks. I have Xcode and the command line tools installed, yet I get this error:
sudo gem install jekyll
Password:
Building native extensions. This could take a while...
ERROR: Error installing jekyll:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
creating Makefile
make "DESTDIR=" clean
make "DESTDIR="
compiling porter.c
porter.c:359:27: warning: '&&' within '||' [-Wlogical-op-parentheses]
if (a > 1 || a == 1 && !cvc(z, z->k - 1)) z->k--;
~~ ~~~~~~~^~~~~~~~~~~~~~~~~~~~
porter.c:359:27: note: place parentheses around the '&&' expression to silence this warning
if (a > 1 || a == 1 && !cvc(z, z->k - 1)) z->k--;
^
( )
1 warning generated.
compiling porter_wrap.c
linking shared-object stemmer.bundle
clang: error: unknown argument: '-multiply_definedsuppress' [-Wunused-command-line-argument-hard-error-in-future]
clang: note: this will be a hard error (cannot be downgraded to a warning) in the future
make: *** [stemmer.bundle] Error 1
make failed, exit code 2
Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/fast-stemmer-1.0.2 for inspection.
Results logged to /Library/Ruby/Gems/2.0.0/extensions/universal-darwin-13/2.0.0/fast-stemmer-1.0.2/gem_make.out

Your problem appeared with Xcode 5.1. In order to avoid many problems related to MacOS' ruby version (this one and many others), you really should use RVM.
If you don't already have it, install Homebrew first: (it is not absolutely necessary, but allows us to install ruby and its dependencies without a looong compilation)
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
Then, the following command will install RVM and the last version of Ruby:
\curl -L https://get.rvm.io | bash -s stable --ruby
Check everything is OK:
ruby --version
You can now install Jekyll:
gem install jekyll
Now, if you really don't want to use RVM, you can execute:
sudo ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future gem install jekyll
But I bet further problems would come.

You should definitely use RVM. Here are the steps:
Uninstall any existing XCode by deleting XCode from Applications folder.
Install Homebrew.
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
Follow additional instructions listed in Homebrew install.
brew doctor
Install RVM.
\curl -L https://get.rvm.io | bash -s stable --ruby
Follow additional instructions upon RVM installation.
source ~/.rvm/scripts/rvm
Install jekyll.
gem install jekyll
Test jekyll.
$ jekyll serve
Configuration file: none
Source: /private/var/log
Destination: /private/var/log/_site
Generating... done.
Server address: ...
Server running... press ctrl-c to stop.

1) xcode-select --install
2) brew install ruby
3) sudo gem install jekyll
4) sudo gem install jekyll-import

Related

Unable to install ruby-filemagic 0.7.1 on Mac even though libmagic has been installed

Unable to install ruby-filemagic 0.7.1 on Mac even though libmagic has been installed.
The error is like :
checking for main() in -lgnurx... no
checking for magic_open() in -lmagic... no
*** ERROR: missing required library to compile this module
* extconf.rb failed *
Almost all answers fo ruby-filemagic installation are the brew install libmagic. However, it doesn't work.
In my case, on Monterey 12.0.1 helped this:
brew unlink libmagic && brew link libmagic
sudo chown -R $(whoami) $(brew --prefix)/* - in case you have Error: Permission denied # rb_sysopen
gem install ruby-filemagic -v '0.7.2' --source 'https://rubygems.org/' -- --with-magic-include=/opt/homebrew/include --with-magic-lib=/opt/homebrew/lib/
A few hours were cost before I found the problem. Let me write down the cause and solution here :
cause:
my ruby ($HOME/.rbenv/versions/x.x.x/bin/ruby) was under the control of rbenv, however my bundler was controlled by old ruby (/usr/local/ruby) .
The stupid bundler could not find the library for installing ruby_filemagic and wasted so much time.
solution:
$ rbenv exec gem install bundler
$ rbenv rehash
make bundler, gem, ruby under the same management.
Sorry for my poor English. I hope this may help more people.

Error on installing ruby with jemalloc

I am on ubuntu 12.04.5 LTS and tried installing ruby with jemalloc. The jemalloc got installed successfully(https://blog.scalingo.com/2017/05/02/improve-ruby-application-memory-jemalloc.html) but while installing the ruby 2.3.4, it gave this following error.
>rvm install 2.3.4 -C --with-jemalloc
Warning, new version of rvm available '1.29.1', you are using older version '1.27.0'.
You can disable this warning with: echo rvm_autoupdate_flag=0 >> ~/.rvmrc
You can enable auto-update with: echo rvm_autoupdate_flag=2 >> ~/.rvmrc
ruby-2.3.4 - #removing src/ruby-2.3.4..
Checking requirements for ubuntu.
Requirements installation successful.
Installing Ruby from source to: /home/deploy/.rvm/rubies/ruby-2.3.4, this may take a while depending on your cpu(s)...
ruby-2.3.4 - #downloading ruby-2.3.4, this may take a while depending on your connection...
ruby-2.3.4 - #extracting ruby-2.3.4 to /home/deploy/.rvm/src/ruby-2.3.4....
ruby-2.3.4 - #configuring...........................................................
ruby-2.3.4 - #post-configuration..
ruby-2.3.4 - #compiling.....
Error running '__rvm_make -j2',
showing last 15 lines of /home/deploy/.rvm/log/1494486344_ruby-2.3.4/make.log
compiling enumerator.c
compiling error.c
compiling eval.c
eval.c: In function 'rb_raise_jump':
eval.c:763:8: warning: unused variable 'mid' [-Wunused-variable]
compiling load.c
compiling proc.c
compiling file.c
compiling gc.c
In file included from gc.c:50:0:
/usr/include/malloc.h:152:15: error: conflicting types for 'malloc_usable_size'
/usr/include/jemalloc/jemalloc.h:45:8: note: previous declaration of 'malloc_usable_size' was here
make: *** [gc.o] Error 1
make: *** Waiting for unfinished jobs....
++ return 2
There has been an error while running make. Halting the installation.
Has anyone encountered it before or may have the experience with it, please help.
On [xK]ubuntu 18.10
I did
sudo apt install libjemalloc-dev
rvm install 2.5.2 -C --with-jemalloc
rvm use 2.5.2
ruby -r rbconfig -e "puts RbConfig::CONFIG['LIBS']"
I use Ubuntu 18.04.
Change the command like this
RUBY_EXTRA_CONFIGURE_OPTIONS="--with-jemalloc" rvm install 2.3.4 --disable-binary
To check the jemalloc is installed, run the following command:
ruby -r rbconfig -e "puts RbConfig::CONFIG['LIBS']"
if the ruby is unrecognized after rvm is installed.
source ~/.rvm/scripts/rvm
When the jemalloc is called. You can see the response.
-lpthread -ljemalloc -ldl -lobjc
You can see the full documentation here
I ran across a variant of this issue when trying to get rails to use jemalloc. In my case I had (purposefully) installed system-wide rubies via rvm but forgotten to use rvmsudo like so:
$ sudo apt update; sudo apt install libjemalloc-dev -y
$ rvmsudo rvm reinstall 2.4.1 -C --with-jemalloc
If you're getting permissions warnings when trying to get jemalloc to work in an analogous scenario, give ^^^ a shot...

Why can't I install Sass on Mac OS? [duplicate]

I am not able to install and run fakes3 gem on El Capitan Beta 5.
I tried:
sudo gem install fakes3
ERROR: While executing gem ... (Errno::EPERM)
Operation not permitted - /usr/bin/fakes3
Then I tried doing it the cocoapods way. It worked for cocoapods but not for fakes3.
mkdir -p $HOME/Software/ruby
export GEM_HOME=$HOME/Software/ruby
gem install cocoapods
[...]
1 gem installed
gem install fakes3
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.
Disclaimer: #theTinMan and other Ruby developers often point out not to use sudo when installing gems and point to things like RVM. That's absolutely true when doing Ruby development. Go ahead and use that.
However, many of us just want some binary that happens to be distributed as a gem (e.g. fakes3, cocoapods, xcpretty …). I definitely don't want to bother with managing a separate ruby. Here are your quicker options:
Option 1: Keep using sudo
Using sudo is probably fine if you want these tools to be installed globally.
The problem is that these binaries are installed into /usr/bin, which is off-limits since El Capitan. However, you can install them into /usr/local/bin instead. That's where Homebrew install its stuff, so it probably exists already.
sudo gem install fakes3 -n/usr/local/bin
Gems will be installed into /usr/local/bin and every user on your system can use them if it's in their PATH.
Option 2: Install in your home directory (without sudo)
The following will install gems in ~/.gem and put binaries in ~/bin (which you should then add to your PATH).
gem install fakes3 --user-install -n~/bin
Make it the default
Either way, you can add these parameters to your ~/.gemrc so you don't have to remember them:
gem: -n/usr/local/bin
i.e. echo "gem: -n/usr/local/bin" >> ~/.gemrc
or
gem: --user-install -n~/bin
i.e. echo "gem: --user-install -n~/bin" >> ~/.gemrc
(Tip: You can also throw in --no-document to skip generating Ruby developer documentation.)
In my case, I had to re-install Ruby using Brew. That seems to have solved the problem as I can install gems again.
brew install ruby
After this, you need to log out and log back in, either graphically or just restarting your terminal.
That is because of the new security function of OS X "El Capitan".
Try adding --user-install instead of using sudo:
$ gem install *** --user-install
For example, if you want to install fake3 just use:
$ gem install fake3 --user-install
sudo gem install -n /usr/local/bin cocoapods
Try this. It will definately work.
You have to update Xcode to the newest one (v7.0.1) and everything will work as normal.
If after you install the newest Xcode and still doesn't work try to install gem in this way:
sudo gem install -n /usr/local/bin GEM_NAME_HERE
For example:
sudo gem install -n /usr/local/bin fakes3
sudo gem install -n /usr/local/bin compass
sudo gem install -n /usr/local/bin susy
Looks like when upgrading to OS X El Capitain, the /usr/local directory is modified in multiple ways :
user permissions are reset (this is also a problem for people using Homebrew)
binaries and symlinks might have been deleted or altered
[Edit] There's also a preliminary thing to do : upgrade Xcode...
Solution for #1 :
$ sudo chown -R $(whoami):admin /usr/local
This will fix permissions on the /usr/local directory which will then help both gem install and brew install|link|... commands working properly.
Solution to #2 :
Ruby based issues
Make sure you have fixed the permissions of the /usr/local directory (see #1 above)
First try to reinstall your gem using :
sudo gem install <gemname>
Note that it will install the latest version of the specified gem.
If you don't want to face backward-compatibility issues, I suggest that you first determine which version of which gem you want to get and then reinstall it with the -v version. See an exemple below to make sure that the system won't get a new version of capistrano.
$ gem list | grep capistrano
capistrano (3.4.0, 3.2.1, 2.14.2)
$ sudo gem install capistrano -v 3.4.0
Brew based issues
Update brew and upgrade your formulas
$ brew update
$ brew upgrade
You might also need to re-link some of them manually
$ brew link <formula>
As it have been said, the issue comes from a security function of Mac OSX since "El Capitan".
Using the default system Ruby, the install process happens in the /Library/Ruby/Gems/2.0.0 directory which is not available to the user and gives the error.
You can have a look to your Ruby environments parameters with the command
$ gem env
There is an INSTALLATION DIRECTORY and a USER INSTALLATION DIRECTORY. To use the user installation directory instead of the default installation directory, you can use --user-install parameter instead as using sudo which is never a recommanded way of doing.
$ gem install myGemName --user-install
There should not be any rights issue anymore in the process. The gems are then installed in the user directory : ~/.gem/Ruby/2.0.0/bin
But to make the installed gems available, this directory should be available in your path. According to the Ruby’s faq, you can add the following line to your ~/.bash_profile or ~/.bashrc
if which ruby >/dev/null && which gem >/dev/null; then
PATH="$(ruby -rubygems -e 'puts Gem.user_dir')/bin:$PATH"
fi
Then close and reload your terminal or reload your .bash_profile or .bashrc (. ~/.bash_profile)
This is the solution that I have used:
Note: this fix is for compass as I wrote it on another SO question, but I have used the same process to restore functionality to all terminal processes, obviously the gems you are installing are different, but the process is the same.
I had the same issue. It is due to Apple implementing System Integrity Protection (SIP). You have to first disable that...
Reboot in recovery mode:
Reboot and hold Command + R until you see the apple logo.
Once booted select Utilities > Terminal from top bar.
type: csrutil disable
then type: reboot
Once rebooted
Open terminal back up and enter the commands:
sudo gem uninstall bundler
sudo gem install bundler
sudo gem install compass
sudo gem install sass
sudo gem update --system
The the individual gems that failed need to be fixed, so for each do the following:
On my machine this was the first dependency not working so I listed it:
sudo gem pristine ffi --version 1.9.3
Proceed through the list of gems that need to be repaired. In all you are looking at about 10 minutes to fix it, but you will have terminal commands for compass working.
Screenshot
If the gem you are trying to install requires xml libraries, then try this:
sudo gem install -n /usr/local/bin <gem_name> -- --use-system-libraries --with-xml2-include=/usr/include/libxml2 --with-xml2-lib=/usr/lib/
Specifically, I ran into a problem while installing the nokogiri gem v 1.6.8 on OS X El Capitan
and this finally worked for me:
sudo gem install -n /usr/local/bin nokogiri -- --use-system-libraries --with-xml2-include=/usr/include/libxml2 --with-xml2-lib=/usr/lib/
To make sure you have libxml2 and libxslt installed, you can do:
brew install libxml2 libxslt
brew install libiconv
and then check to make sure you have xcode command line tools installed:
xcode-select --install
should return this error:
xcode-select: error: command line tools are already installed, use "Software Update" to install updates
Reinstalling RVM worked for me, but I had to reinstall all of my gems afterward:
rvm implode
\curl -sSL https://get.rvm.io | bash -s stable --ruby
rvm reload
I ran across the same issue after installing El Capitan, I tried to install sass and compass into a symfony project, the following command returned the following error:
$ sudo gem install compass
ERROR: Error installing compass:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
checking for ffi.h... /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/mkmf.rb:434:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
So I then tried to install sass with:
$ sudo gem install sass
Got the same error message, after some googling I managed to install sass using the following command:
$ sudo gem install -n /usr/local/bin sass
The above worked for me with installing sass but did not work for installing compass. I read that someone somewhere had opened an instance of xcode then closed it again, then successfully ran the same command after which worked for them.
I attempted to open xcode but was prompted with a message saying that the version of xcode installed was not compatible with El Capitan.
So I then updated xcode from the app store, re-ran the following command which this time ran successfully:
$ sudo gem install -n /usr/local/bin compass
I was then able to run $ compass init
I now have all my gems working and can proceed to build some lovely sass stuff :)
I had to rm -rf ./vendor then run bundle install again.
You might have two options:
If you've installed ruby and rails, you can first try running the command:
rvm fix-permissions
You can uninstall ruby completely, and reinstall in your ~ directory aka your home directory.
If you're using homebrew the command is:
brew uninstall ruby
For rails uninstall without homebrew the command is:
rvm remove
This should reinstall the latest ruby by running command:
curl -L https://get.rvm.io | bash -s stable --rails<br>
Mac has 2.6.3 factory installed, and it's required... if not run this command:
rvm install "ruby-2.6.3"
and then:
gem install rails
You'll get a few error messages at the end saying you have to add some other bundles...
Just make sure you're in the home ~ directory when you're installing so the permissions won't be an issue, but just in case...
I again ran:
rvm fix-permissions
and:
rvm debug
which told me I had to download yarn, I didn't save the output for it. Basically I did whatever the prompt told me to do if it had to do with my OS.
-D
I don't like to install stuff with sudo.
once you start with sudo you can't stop..
try giving permissions to the Gems directory.
sudo chown -R $(whoami) /Library/Ruby/Gems/2.0.0
sudo chown -R $(whoami):admin /usr/local
That will give permissions back (Homebrew installs ruby there)

gem install compass won't work

When I try to install compass using sudo gem install compass it show me this :
Building native extensions. This could take a while...
ERROR: Error installing compass:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -r ./siteconf20141125-86718-gjziv3-0.rb extconf.rb
checking for ffi.h... no
checking for ffi.h in /usr/local/include,/usr/include/ffi... no
checking for rb_thread_blocking_region()... no
checking for rb_thread_call_with_gvl()... no
checking for rb_thread_call_without_gvl()... no
checking for ffi_prep_cif_var()... no
creating extconf.h
creating Makefile
make clean
make
mkdir -p "/Library/Ruby/Gems/1.8/gems/ffi-1.9.6/ext/ffi_c"/libffi-i386; (if [ ! -f "/Library/Ruby/Gems/1.8/gems/ffi-1.9.6/ext/ffi_c"/libffi-i386/Makefile ]; then echo "Configuring libffi for i386"; cd "/Library/Ruby/Gems/1.8/gems/ffi-1.9.6/ext/ffi_c"/libffi-i386 && env CC=" xcrun cc" CFLAGS="-arch i386 " LDFLAGS="-arch i386" "/Library/Ruby/Gems/1.8/gems/ffi-1.9.6/ext/ffi_c/libffi"/configure --disable-static --with-pic=yes --disable-dependency-tracking --host=i386-apple-darwin > /dev/null; fi); env MACOSX_DEPLOYMENT_TARGET=10.4 make -C "/Library/Ruby/Gems/1.8/gems/ffi-1.9.6/ext/ffi_c"/libffi-i386
Configuring libffi for i386
configure: WARNING: if you wanted to set the --build type, don't use --host.
If a cross compiler is detected then cross compile mode will be used
configure: error: in `/Library/Ruby/Gems/1.8/gems/ffi-1.9.6/ext/ffi_c/libffi-i386':
configure: error: C compiler cannot create executables
See `config.log' for more details
make[1]: *** No targets specified and no makefile found. Stop.
make: *** ["/Library/Ruby/Gems/1.8/gems/ffi-1.9.6/ext/ffi_c"/libffi-i386/.libs/libffi_convenience.a] Error 2
make failed, exit code 2
Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/ffi-1.9.6 for inspection.
Results logged to /Library/Ruby/Gems/1.8/extensions/universal-darwin-11/1.8/ffi-1.9.6/gem_make.out
I have correctly install sass and xcode' tools but nothing change. I even try to upgrade ruby. What should I do?
It happens because you want to sudo install and probably environment variables are not configured to use your installed ruby, instead it uses the system ruby which probably is not what you want to use.
The easiest way to use Ruby on Mac is to install rbenv and ruby-build using homebrew.
To install homebrew just run this command which can be found on brew homepage:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
To install rbenv and ruby-build you can run these commands which can be found on Github:
brew update
brew install rbenv ruby-build
Forgot to add that for sure, then you need to install a ruby version using rbenv and make it global.
rbenv install 2.1.5
rbenv global 2.1.5
And finally:
gem install compass
Just make sure that gem binary points to the version you've installed.
You can run gem env and checkout printed paths, if it doesn't point to newly installed ruby gem path, close the terminal and open a new one then install the gem.
Here is the first few lines of what's printed out on my machine:
RubyGems Environment:
- RUBYGEMS VERSION: 2.2.0
- RUBY VERSION: 2.1.0 (2013-12-25 patchlevel 0) [x86_64-darwin13.0]
- INSTALLATION DIRECTORY: /Users/jani/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0
....

Can't install ruby-ldap under Windows/Cygwin

gem install ruby-ldap
Building native extensions. This could take a while...
ERROR: Error installing ruby-ldap:
ERROR: Failed to build gem native extension.
/usr/bin/ruby.exe extconf.rb
--with-ldap-dir=/usr
--with-openldap2
checking for ldap.h... yes
[...]
creating Makefile
make
gcc -I. -I. -I/usr/lib/ruby/1.8/i386-cygwin -I. ...
[...]
gcc -shared -s -o ldap.so ...
The configuration and the compilation works just fine. But the installation throws this error:
make install
/usr/bin/install -c -m 0755 ldap.so /usr/lib/ruby/gems/1.8/gems/ruby-ldap-0.9.12/lib
/usr/bin/install -c -m 644 ./lib/ldap/control.rb /usr/lib/ruby/gems/1.8/gems/ruby-ldap-0.9.12/lib/ldap
/usr/bin/install: `./lib/ldap/control.rb' and `/usr/lib/ruby/gems/1.8/gems/ruby-ldap-0.9.12/lib/ldap/control.rb' are the same file
Makefile:130: recipe for target `/usr/lib/ruby/gems/1.8/gems/ruby-ldap-0.9.12/lib/ldap/control.rb' failed
make: *** [/usr/lib/ruby/gems/1.8/gems/ruby-ldap-0.9.12/lib/ldap/control.rb] Error 1
./lib/ldap/control.rb and /usr/lib/ruby/gems/1.8/gems/ruby-ldap-0.9.12/lib/ldap/control.rb are indeed the same file, but why? Other gems with nativ bindings like mysql worked just fine. I reported this as a bug, but some other guy does not have the problem, so the package itself is intact.
If I download the gem and run:
ruby extconf.rb
make install
The Makefile runs just fine.
It must be my system/configuration. Whats going wrong here?
Wow, very oddly, I got this working by downgrading RubyGems and then upgrading it back. I downgraded it first to match a version (1.4.1) I had on another system that could install ruby-ldap just fine. I thought this might make it work on my current system, but I got the same error you did. I upgraded RubyGems back to what I had (1.8.15), then it all magically worked.
So:
$ gem update --system 1.4.1 # Downgrade to 1.4.1
...
$ gem update --system # Go back to current
...
$ gem install ruby-ldap
Building native extensions. This could take a while...
Successfully installed ruby-ldap-0.9.12
1 gem installed
Installing ri documentation for ruby-ldap-0.9.12...
Installing RDoc documentation for ruby-ldap-0.9.12...
$
FYI, I didn't have to use sudo because I'm using rvm and I was installing ruby-ldap into a per-project gemset.
If you are using Ubunty, try to perform
sudo apt-get install libsasl2-dev
More about it at https://github.com/alexey-chebotar/ruby-ldap/issues/7

Resources