Hola readers,

Many questions might have come across your mind on seeing the title. It says installing ‘Scheme’. Well I am not talking about any offers or daily schemes :P. Scheme is a functional programming language, a variation to LISP programming language.

And other thing that might come across would be why am I talking about Mac OS when my earlier posts were all related to Open Source or Linux in some or the other way. IMHO, Mac is best of both worlds, an awesome GUI by Apple designers and Linux like command line interface backed by Unix. Most of the developers prefer Mac and hence there are lots of awesome IDE available for it. I do most of my programming on X-Code. Using command line tools I can write programs through terminal too using vi and Emacs (I prefer vi/vim). I run Linux on VBox for my Open Source contributions and enjoy best of both worlds :D.

This is my second post of the day. You would be thinking that I am on some kind of blogging spree, well am also thinking the same :P. Reason to post about this is that I was talking to my friend about MPLAB IDE for Mac and then he mentioned that he couldn’t even get his MIT-Scheme running on Mac OS X. Maybe there would be others too facing the same problem, so why not share my knowledge with the world 🙂

In this post, I am going to help you with setting up MIT-Scheme (implementation of Scheme programming language developed by MIT) for Mac OS X.

First of all, you will need to download the .dmg file of MIT Scheme.

Download link for OS X:

32-bit system

64-bit system

Click on the downloaded dmg file and a finder window will open up like this:

MIT-Scheme disk image
MIT-Scheme disk image

Just drag the MIT/GNU Scheme.app into the Applications folder and it will be installed in your system.

Now to use Scheme through command line, open up Terminal.app from either Launchpad, Spotlight or under Applications folder and run the following command.

For 32-bit package:

sudo ln -s /Applications/MIT\:GNU\ Scheme.app/Contents/Resources /usr/local/lib/mit-scheme-i386

For 64-bit package:

sudo ln -s /Applications/MIT\:GNU\ Scheme.app/Contents/Resources /usr/local/lib/mit-scheme-x86-64

You will need to enter your administrator password. Now run the following command to link mit-scheme.app to ‘scheme’ command in terminal:

For 32-bit package:

sudo ln -s /usr/local/lib/mit-scheme-i386/mit-scheme /usr/bin/scheme

For 64-bit package:

sudo ln -s /usr/local/lib/mit-scheme-x86-64/mit-scheme /usr/bin/scheme

Note: As SIP was introduced in El-Capitan, the above commands might not work. You can run the above commands by replacing ‘/usr/bin/scheme’ with ‘/usr/local/bin/scheme’

To use Scheme open up Terminal.app and simply run:

scheme

P.S.: You can even create an alias if the symlink doesn’t work. You can do so by adding the following line in your ~/.bash_profile

alias scheme="/Applications/MIT\:GNU\ Scheme.app/Contents/Resources/mit-scheme"

Happy Coding \m/

Let the Windows be open, and feel the Freedom.

Advertisements

37 thoughts on “Installing Scheme on Mac OS X

  1. 🙂 Your love for helping inspires me.

    And when I saw “Let the Windows be open, and feel the Freedom”, with the picture of a happy lady, I felt happy too. ^_^

    Thank you for what you do. ❤

    Like

    1. Hi,

      This is because SIP (System Integrity Protection) restricts the user to modify some files/dir even when they are ‘root’. This is to protect malwares getting root access by accident. More on ‘rootless’: http://apple.stackexchange.com/a/193379

      I found a stackexchange answer over here for a workaround: http://apple.stackexchange.com/a/196226

      I’ll update once I get my hands on El Capitan.

      Note: You can even use MacPorts to install mit-scheme on your machine. Link: https://trac.macports.org/wiki/Migration

      Like

    2. Can you give more information about the error, which step you tried and got this error ? Can you paste your log on sites like https://dpaste.de and share the link.

      If you tried the step to add symlink from /usr/local/lib/mit-scheme-i386 to /usr/bin and got the error then you can try adding /usr/local/lib/mit-scheme-i386 to your $PATH

      i.e., Add the following line in your ~/.bash_profile

      export PATH="/usr/local/lib/mit-scheme-i386:$PATH
      

      and run scheme using the command ‘mit-scheme’ as this is the name of the binary in ‘/usr/local/lib/mit-scheme-i386/’

      Like

      1. I think I got it working in that I wound up with the following in my Terminal window: 1 ]=>
        Not knowing what to do I can only close the Terminal window. I’ve tried looking for documentation, but can’t find any to test the program. Is this Scheme I’m looking at? If so, what do I do to get a “Hello World”?

        Like

  2. I did get Scheme running. I installed the dmg then went into the Terminal. I typed cd/Applications/mit-scheme-0.2-x86-64.app/Contents/Resources followed by the Return key. Then type ./mit-scheme followed by the Return key. Scheme starts. I found some documentation online as well as a “Hello World”. I didn’t change anything as far as the app location.

    Like

    1. Yes this is one way to run. But to run scheme from anywhere in the environment I.e., terminal we need to add the location to our path. Can you try the other method that I posted previously regarding adding the path to ~/.bash_profile.

      Like

    2. Hi,

      I have updated the post and you can try adding an alias (see P.S. in the post) and typing ‘scheme’ in terminal will just work fine.

      If you get ‘1 ]=>’ that means the scheme is running. Also it will print out “MIT/GNU Scheme running under OS X” and the license below it.

      Like

  3. Hey,it does help.
    But there is a small typo:
    alias scehme=”/Applications/MIT\:GNU\ Scheme.app/Contents/Resources/mit-scheme”
    “scehme” =>”scheme”

    Like

  4. Hello, I did what you suggested, and I received “Inconsistency detected” Please help. Thank you.
    Last login: Sun Jul 2 19:41:40 on ttys000
    Suzettes-MacBook-Air:~ suzettebuckley$ sudo ln -s /Applications/MIT\:GNU\ Scheme.app/Contents/Resources /usr/local/lib/mit-scheme-x86-64
    Password:
    ln: /usr/local/lib/mit-scheme-x86-64: No such file or directory
    Suzettes-MacBook-Air:~ suzettebuckley$ sudo ln -s /usr/local/lib/mit-scheme-x86-64/mit-scheme /usr/local/bin/scheme
    Suzettes-MacBook-Air:~ suzettebuckley$
    Suzettes-MacBook-Air:~ suzettebuckley$ scheme
    -bash: scheme: command not found
    Suzettes-MacBook-Air:~ suzettebuckley$ sudo ln -s /usr/local/lib/mit-scheme-x86-64/mit-scheme /usr/local/bin/scheme
    ln: /usr/local/bin/scheme: File exists
    Suzettes-MacBook-Air:~ suzettebuckley$ alias scheme=”/Applications/MIT\:GNU\ Scheme.app/Contents/Resources/mit-scheme”
    Suzettes-MacBook-Air:~ suzettebuckley$ scheme
    /Applications/MIT:GNU Scheme.app/Contents/Resources/mit-scheme: can’t find a readable default for option –band.
    searched for file all.com in these directories:
    /Applications/MIT:GNU Scheme.app/Contents/Resourcesme.app/Con
    /usr/local/lib/mit-scheme-x86-64

    Inconsistency detected.
    Suzettes-MacBook-Air:~ suzettebuckley$

    Like

      1. Hi, after reloading terminal and typing scheme I’ve received the error message “command not found”
        Thank you

        Like

    1. I guess you forgot to add this line ‘alias scheme=”/Applications/MIT\:GNU\ Scheme.app/Contents/Resources/mit-scheme”’ (remove single quotes) in ~/.bash_profile. From your logs, looks like you ran this as a command.

      Like

    1. Yes through terminal. If the alias is set you can start scheme by just entering ‘scheme’. Else you can also run it by entering ‘/Applications/MIT\:GNU\ Scheme.app/Contents/Resources/mit-scheme’.

      Like

  5. Also, how do I save the changes. I exited terminal and then returned and I got the command “inconsistency detected” again after calling for scheme

    Like

  6. Last login: Sun Jul 9 10:58:08 on ttys000
    Suzettes-MacBook-Air:~ suzettebuckley$ sudo ln -s /Applications/MIT\:GNU\ Scheme.app/Contents/Resources /usr/local/lib/mit-scheme-x86-64
    Password:
    ln: /usr/local/lib/mit-scheme-x86-64: No such file or directory
    Suzettes-MacBook-Air:~ suzettebuckley$ sudo ln -s /usr/local/lib/mit-scheme-x86-64/mit-scheme /usr/local/bin/scheme
    ln: /usr/local/bin/scheme: File exists
    Suzettes-MacBook-Air:~ suzettebuckley$ scheme
    -bash: scheme: command not found
    Suzettes-MacBook-Air:~ suzettebuckley$ Scheme
    -bash: Scheme: command not found
    Suzettes-MacBook-Air:~ suzettebuckley$ alias scheme=”/Applications/MIT\:GNU\ Scheme.app/Contents/Resources/mit-scheme”
    Suzettes-MacBook-Air:~ suzettebuckley$ Scheme
    -bash: Scheme: command not found
    Suzettes-MacBook-Air:~ suzettebuckley$ alias scheme=”/Applications/MIT\:GNU\ Scheme.app/Contents/Resources/mit-scheme”
    Suzettes-MacBook-Air:~ suzettebuckley$
    Suzettes-MacBook-Air:~ suzettebuckley$ scheme
    MIT/GNU Scheme running under OS X
    Type `^C’ (control-C) followed by `H’ to obtain information about interrupts.

    Copyright (C) 2014 Massachusetts Institute of Technology
    This is free software; see the source for copying conditions. There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

    Image saved on Saturday May 17, 2014 at 2:39:25 AM
    Release 9.2 || Microcode 15.3 || Runtime 15.7 || SF 4.41 || LIAR/x86-64 4.118
    Edwin 3.116

    1 ]=>

    But, I have to copy and paste your three links every time. Is that common or am I missing something? Thank you again for your help!

    Like

    1. Well actually you don’t need to run all the commands again and again. I’ll point out the mistake in a sec.

      Firstly, “sudo ln -s /usr/local/lib/mit-scheme-x86-64/mit-scheme /usr/local/bin/scheme
      ln: /usr/local/bin/scheme: File exists” This tells that the symlink (copy of file/shortcut in Windows terms) exists. So no need to run this command every time.

      Secondly, is not a command but rather you need to put this line in ~./bash_profile. This is done so that the terminal knows to load this automatically whenever a new terminal/tab is opened.
      Run this on the terminal once – echo ‘alias scheme=”/Applications/MIT\:GNU\ Scheme.app/Contents/Resources/mit-scheme”’ >> ~/.bash_profile && source ~/.bash_profile

      After this whenever you open terminal typing ‘scheme’ should work fine. Let me know if it works or not after adding alias to bash_profile rather than running it as command.

      Like

  7. So I copy/pasted echo ‘alias scheme=”/Applications/MIT\:GNU\ Scheme.app/Contents/Resources/mit-scheme”’ >> ~/.bash_profile && source ~/.bash_profile Into terminal and it responded -bash: ‘alias: command not found

    Like

    1. You can edit bash_profile by running open ~/.bash_profile. You can find the line at the end of file, just remove the ‘ and re-type “.

      When you copy paste on terminal, make sure that you retype the quote ‘ and “. It does copy the line into bash_profile, but only problem is the copy pasted ‘ and ” are not recognized by bash since they look like special characters (because of different formatting on the blog).

      Like

  8. Hello again,
    Good morning. So I did what you said and typed ~/.bash_profile Terminal responded with “permission denied” So I did some digging on the internet and figured out how to bypass that. I’m in bash. But, I want to make sure what I do next is correct the first time. I’m including a copy of Terminal text for you to look over before I retype the alias you’ve suggested. Thank you(:

    Like

  9. Hello again,
    Good morning. So I did what you said and typed ~/.bash_profile Terminal responded with “permission denied” So I did some digging on the internet and figured out how to bypass that. I’m in bash. But, I want to make sure what I do next is correct the first time. I’m including a copy of Terminal text for you to look over before I retype the alias you’ve suggested. Thank you(:
    TERMINAL WINDOW STATUS BAR SAYS: .bash_profile

    # Setting PATH for Python 3.5
    # The original version is saved in .bash_profile.pysave
    PATH=”/Library/Frameworks/Python.framework/Versions/3.5/bin:${PATH}”
    export PATH

    # Setting PATH for Python 3.6
    # The original version is saved in .bash_profile.pysave
    PATH=”/Library/Frameworks/Python.framework/Versions/3.6/bin:${PATH}”
    export PATH

    # Setting PATH for Python 3.6
    # The original version is saved in .bash_profile.pysave
    PATH=”/Library/Frameworks/Python.framework/Versions/3.6/bin:${PATH}”
    export PATH
    ‘alias scheme=”/Applications/MIT:GNU Scheme.app/Contents/Resources/mit-scheme”’

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s