LoginSignup
1
1

More than 5 years have passed since last update.

How to install Crystal on OSX El Capitan

Last updated at Posted at 2015-10-21

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

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1