Sunday, November 25, 2018

MacOSX Ruby installation, GitHub.io and Jekyll

Under construction. Do not use.

Ruby installation on MacOSX is not clean...these are the steps I had to take to get it to work. There are all sorts of paths in packages such as Anaconda which conflict with the paths to packages installed by Brew which are required for the installation of Ruby. Thanks to the GitHub, stack overflow, and superuser posts I was able to install Ruby in the end.

$ xcode-select --install

https://github.com/rbenv/ruby-build/wiki#updating-ruby-build

Check the installation

https://github.com/rbenv/rbenv-installer#rbenv-doctor

gem pristine gem-wrappers --version 1.4.0
rbenv install 2.5.1

https://help.github.com/articles/setting-up-your-github-pages-site-locally-with-jekyll/

gem install bundler

brew install rbenv
  echo $PATH
add eval "$(rbenv init -)" to ~/.bash_profile or what ever your startup script is
  source ~/.bash_profile
  which ruby-build
 3705  ls "$(rbenv root)"/plugins
 3706  ls "$(rbenv root)"/
 3707  rbenv init
 3708  eval "$(rbenv init -)"
 3709  curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-doctor | bash
 3710  brew upgrade rbenv ruby-build
 3711  rbenv install -l
 3712  gem pristine gem-wrappers --version 1.4.0
 3713  rbenv install 2.5.1
 3715  cd .github.io/
 3716  gem install bundler

 3719  more Gemfile
 3720  bundle install

==============================================

brew uninstall perl
brew install perl
brew link --force openssl
brew link --force gettext
brew install gpg2
$ curl -sSL https://rvm.io/mpapis.asc | gpg --import -
gpg: key 3804BB82D39DC0E3: 47 signatures not checked due to missing keys
gpg: key 3804BB82D39DC0E3: public key "Michal Papis (RVM signing) " imported
gpg: Total number processed: 1
gpg:               imported: 1
gpg: no ultimately trusted keys found

 \curl -sSL https://get.rvm.io | bash -s stable --autolibs=enabled

eval "$(rbenv init -)

add to ~/.bash_profile 
export PATH="/usr/local/opt/openssl/bin:$PATH"
  1. brew unlink openssl
  2. brew uninstall --ignore-dependencies openssl
  3. Repeat number 2 until all deps are gone
  4. brew install openssl
  5. Follow post install instructions:
If you need to have this software first in your PATH run:
      echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.zshrc


        For compilers to find this software you may need to set:
              LDFLAGS:  -L/usr/local/opt/openssl/lib
                CPPFLAGS: -I/usr/local/opt/openssl/include
              For pkg-config to find this software you may need to set:
                    PKG_CONFIG_PATH: /usr/local/opt/openssl/lib/pkgconfig

                $ export LDFLAGS=" -L/usr/local/opt/openssl/lib"
                $ export CPPFLAGS="-I/usr/local/opt/openssl/include"
                $ export PKG_CONFIG_PATH="/usr/local/opt/openssl/lib/pkgconfig"


                https://www.codementor.io/akabiru/3-steps-set-up-ruby-environment-macos-6mavm7jrl

                brew install ruby

                brew install ruby

                $ curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-doctor | bash
                Checking for `rbenv' in PATH: /usr/local/bin/rbenv
                Checking for rbenv shims in PATH: OK
                Checking `rbenv install' support: /usr/local/bin/rbenv-install (ruby-build 20181019)
                Counting installed Ruby versions: none
                  There aren't any Ruby versions installed under `/Users/depappas/.rbenv/versions'.
                  You can install Ruby versions like so: rbenv install 2.2.4
                Checking RubyGems settings: OK
                Auditing installed plugins: OK

                 rbenv install 2.3.1
                /usr/local/bin/ruby-build: /usr/local/bin/shasum: /usr/local/opt/perl/bin/perl: bad interpreter: No such file or directory
                ruby-build: use openssl from homebrew
                Downloading ruby-2.3.1.tar.bz2...
                -> https://cache.ruby-lang.org/pub/ruby/2.3/ruby-2.3.1.tar.bz2
                Installing ruby-2.3.1...
                ruby-build: use readline from homebrew

                BUILD FAILED (OS X 10.13.6 using ruby-build 20181019)

                Inspect or clean up the working tree at /var/folders/wx/88s0zlc92wvd9hczwkly7qqh0000gp/T/ruby-build.20181125184727.32663
                Results logged to /var/folders/wx/88s0zlc92wvd9hczwkly7qqh0000gp/T/ruby-build.20181125184727.32663.log

                Last 10 log lines:
                checking for long long... yes
                checking for off_t... yes
                checking char bit... 8
                checking size of int... 0
                checking size of short... 0
                checking size of long... 0
                checking size of long long... configure: error: in `/var/folders/wx/88s0zlc92wvd9hczwkly7qqh0000gp/T/ruby-build.20181125184727.32663/ruby-2.3.1':
                configure: error: cannot compute sizeof (long long)
                See `config.log' for more details
                make: *** No targets specified and no makefile found.  Stop.

                https://github.com/rbenv/rbenv/issues/1059

                https://superuser.com/questions/1296016/rvm-error-running-configure

                "I faced the same issue after migrating my Mac too (both MacOS High Sierra).  After running"
                $ sudo mv /usr/local/include /usr/local/include_old
                "and then"
                $ rvm install 2.5.0 --with-openssl-dir=/usr/local/opt/openssl/bin/openssl


                More ruby build solutions:
                https://github.com/rbenv/ruby-build/wiki#updating-ruby-build


                https://medium.com/@vovakuzmenkov/get-a-website-with-github-pages-9151ed636446

                https://jekyllrb.com/docs/installation/macos/

                ================================================

                Some of the problems I ran into. Solutions above.

                https://gist.github.com/DirtyF/5d2bde5c682101b7b5d90708ad333bf3

                ==> Installing rbenv dependency: ruby-build
                Error: An exception occurred within a child process:
                  RuntimeError: /usr/local/opt/openssl not present or broken
                Please reinstall openssl. Sorry :(

                $ brew remove openssl
                $ brew install openssl
                $ ls -l /usr/local/opt/openssl

                https://gist.githubusercontent.com/DirtyF/5d2bde5c682101b7b5d90708ad333bf3/raw/fbc736fa1b50bd637929a315e6803df306c8bc8e/setup-rbenv.sh

                You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory #938

                https://github.com/rbenv/rbenv-installer#rbenv-doctor


                https://github.com/rbenv/rbenv/issues/938

                "I'm not sure I installed rbenv and a ruby version correctly"
                Yep, sure it can be tricky.
                1. sudo xcode-select --install
                2. Install rbenv with brew install rbenv
                3. Add eval "$(rbenv init -)" to the end of ~/.zshrc or ~/.bash_profile
                4. Install a ruby version rbenv install 2.3.0
                5. Select a ruby version by rbenv rbenv global 2.3.0
                6. Open a new terminal window
                7. Verify that the right gem folder is being used with gem env home (should report something in your user folder not system wide)
                "I want to use bundler and rbenv together"
                Perfect match!
                1. Make sure you installed rbenv correctly ☝️
                2. Select a ruby version locally for the folder you are located in e.g. rbenv local 2.3.0 (this creates a file called .ruby-version in the directory)
                3. Verify that the right gem folder is being used with gem env home (should report something in your user folder not system wide)
                4. Run gem install bundler
                5. Run bundle install
                6. Run on of your favorite gems defined in the Gemfile by bundle exec ... e.g. bundle exec fastlane


                set -ex
                brew update
                brew install rbenv ruby-build
                rbenv install 2.5.3
                rbenv global 2.5.3
                ruby -v
                gem install jekyll bundler
                rbenv rehash
                
                if ! type rbenv | grep function; then
                  echo 'if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi' >> ~/.bash_profile
                fi
                
                set +x
                echo "Done! Close and reopen your terminal"


                https://help.github.com/articles/setting-up-your-github-pages-site-locally-with-jekyll/

                https://help.github.com/articles/using-jekyll-as-a-static-site-generator-with-github-pages/


                No comments:

                Post a Comment