1
Help us understand the problem. What are the problem?

More than 5 years have passed since last update.

posted at

updated at

How to install Crystal on OSX El Capitan

Due to the rootless feature, original pkg installation would be incomplete.

Of course, homebrew users should use brew, but this is not an option for MacPorts (or Fink) users.

Using darwin-x86_64.tar.gz

  • Extract tar.gz into /opt/crystal
  • Link /opt/crystal/bin/crystal and /opt/crystal/embedded/bin/shards to /usr/local/bin.

Using pkg

  • You need to modify the pkg to symlink safely.
  1. Prepare updatepkgscripts.rb.
  2. Paste following to crystal-update.rb.
  3. Call crystal-update.rb updatepkgscripts.rb crystal.pkg.
  4. Now you can install the pkg safely.
crystal-update.rb
#!/usr/bin/ruby
#usage: crystal-update.rb updatepkgscripts.rb crystal.pkg

require 'tmpdir'
Dir.mktmpdir{|tmp|
    system('"'+ARGV[0]+'" -x "'+ARGV[1]+'" crystal-core.pkg/Scripts "'+tmp+'"')
    File.open(tmp+'/postinstall','wb'){|f|
        f.write DATA.read
    }
    system('"'+ARGV[0]+'" -u "'+ARGV[1]+'" crystal-core.pkg/Scripts "'+tmp+'"')
}

__END__
#!/bin/bash
#
# Perform necessary crystal setup steps
# after package is installed.
#

PROGNAME=$(basename $0)

function error_exit
{
  echo "${PROGNAME}: ${1:-"Unknown Error"}" 1>&2
  exit 1
}

INSTALL_PATH=/usr
if [ `uname` = "Darwin" -a `uname -r|cut -f1 -d.` -ge 15 ]; then
  INSTALL_PATH=/usr/local
fi

ln -nfs /opt/crystal/bin/crystal ${INSTALL_PATH}/bin/crystal
ln -nfs /opt/crystal/embedded/bin/shards ${INSTALL_PATH}/bin/shards

exit 0

Appendix

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
1
Help us understand the problem. What are the problem?