Ocamlmerlin Move It Away and Try Again
Installing OCaml for 3110
These installation instructions assume a bones working cognition of the "command line" or "concluding", which is used (eastward.1000.) in CS 1110. If you need to brush upward on the control line, information technology would be a proficient idea to google for a tutorial.
You need to have a Unix evolution surround with a working installation of OPAM, the OCaml Package Manager, version 2.x. You have a choice: you can install these on your own operating organisation, or you can download a Linux virtual automobile (VM) that we provide.
-
For Linux or Mac OS 10, nosotros propose trying a native installation outset. If that doesn't piece of work out, install the VM instead.
-
For Windows, we suggest trying a semi-native installation commencement. This is a new and experimental possibility; we haven't been able to support it before in 3110. It's made possible this semester by some advances that Microsoft has recently made with integration of Linux and Windows. We hope it works out, simply delight carry in mind that it's new to the class staff, so we might non take all the answers right away. If information technology doesn't work out, you can still use the VM, which is what we've recommended in the past for Windows.
Regardless of what you cull, once you get an installation working proceed it working throughout the semester past being cautious about any updates you apply to your system. Don't perform any major Os upgrades just before an assignment is due, for instance.
Click on the installation method below that y'all want to use. If yous get stuck, delight follow the instructions under "Need help?".
- VM installation
- Semi-native installation: Windows
- Native installation: Bone Ten
- Native installation: Linux
- OPAM configuration
- VS Lawmaking configuration
- Need help?
VM installation
WARNING: Do not use a VM from an old edition of CS 3110. Only the Fall 2019 VM volition exist supported this semester.
With Virtual Machines, there are ii operating systems involved: the host operating system (OS) and the guest OS. The host is your ain native Bone (probably Windows). The guest is the OS that runs "inside" the host. We provide a Linux guest Bone in the 3110 VM.
-
Download and install VirtualBox for your host OS. Or, if you already had it installed, make sure you update to the latest version of VirtualBox before proceeding.
-
Go to the 3110 virtual machine download page (that hyperlink will get active shortly before the semester starts). Don't worry most the "We're sorry, the preview didn't load" message y'all see at that link. Click the Download button and save the
.ova
file wherever yous like. It'due south about a 4GB file, so the download might take awhile. -
Import the virtual machine:
-
Run VirtualBox.
-
Select File → Import Appliance
-
Choose the
.ova
file you merely downloaded. Click Adjacent, so Import.
-
-
Run the virtual auto:
-
Select vm3110-2019fa from the listing of machines in VirtualBox.
-
Click Start.
-
If you lot get an error about "VT-x/AMD-V hardware acceleration", you most likely demand to enter your computer's BIOS settings and enable virtualization. The details of that will vary depending on the model and manufacturer of your computer. If you go stuck, please see a consultant for aid.
-
-
Login with username
vagrant
and passwordvagrant
.(In case you're curious, this is the standard username/password on a VM congenital with Vagrant, which is what nosotros use to automate our production of the VM. In fact, you tin see the scripts nosotros use to build the VM in this GitHub repo. If you'd rather have a user account on the VM with your own username rather than
vagrant
, you are welcome to create a new account. Just exist aware that OPAM and VS Code won't be configured for that user. The instructions to do that initialization can be constitute below under "OPAM configuration" and "VS Code configuration".) -
To launch the OCaml toplevel:
-
Start a concluding by choosing the second icon down from the top in the launcher on the left-hand side of the desktop.
-
Run
utop
. Enter3110;;
followed past the Enter key to evaluate the integer 3110. Stop to appreciate how good an integer it is. -
Enter
#quit;;
or Control-D to exit the toplevel.
-
-
You lot can use the guest OS'south ain interface to safely shutdown or reboot the VM. But more oftentimes you will likely use VirtualBox to close the VM past click the VM window's "X" icon in the host OS. Then you will be presented with three choices:
-
Salvage the machine land. This selection is what you ordinarily want. Information technology's similar closing the lid on your laptop: it puts it to sleep, and information technology can quickly wake.
-
Send the shutdown signal. This selection is like shutting down a machine you don't intend to apply for a long time, or before unplugging a desktop automobile from the wall. When yous offset the automobile again later, it will have to boot from scratch, which takes longer.
-
Power off the automobile. This choice is dangerous. It is the equivalent of pulling the power cord of a desktop motorcar from the wall while the motorcar is still running: information technology causes the operating organisation to suddenly quit without doing any cleanup. Doing this even just a handful of times could cause the file system to become corrupted, which volition cause you to lose your source code and have to reinstall the VM from scratch. You will be very unhappy.
-
-
Now setup a shared folder between the host and guest Os.
-
With the VM shutdown (i.due east., select "send the shutdown bespeak"), click Settings, then click Shared Folders.
-
Click the picayune icon on the right that looks like a folder with a plus sign.
-
In the dialog box, select a Folder Path. This is the folder on your host Bone that y'all want to share with the guest OS. Let'south assume you created a new folder named
vmshared
inside your Documents folder, or wherever you like to go on files. -
The Binder Name in the dialog box volition automatically be filled with
vmshared
. This is the proper noun by which the invitee Bone will know the binder. You can change it if you like. -
Check Auto-mount and Make Permanent; do not check Read-merely. Make the Mount Point
/abode/vagrant
. Click OK, and then click OK again. -
Start the VM over again.
-
You should now have a subdirectory named
vmshared
in your home directory. It is shared betwixt the host OS and the invitee OS. Y'all tin can utilize it to easily transfer files between the two.
-
-
-
Y'all're washed!
-
If you lot wish, you can safely delete the
.ova
file you downloaded to free upwards some infinite. -
Y'all might be able to meliorate the performance of your VM by increasing the corporeality of retentiveness or CPUs allocated to it, though it depends on how much your actual machine has bachelor and what else you have running at the same fourth dimension. With the VM shut downwardly, try going in Virtual Box to Settings → Organization, and tinkering with the Base of operations Memory slider on the Motherboard tab, and the Processors slider on the Processor tab. And then bring up the VM again and see how it does. You might accept to play around to detect a sweet spot.
Semi-native installation: Windows
Overview: We're going to install a Linux environment inside Windows 10. Microsoft calls it the "Windows Subsystem for Linux" (WSL). Then we'll install inside OPAM inside WSL. Here is an (optional) introduction to what WSL is and why you demand it.
-
Don't skip this first stride: in beta testing of these instructions, most problems resulted from having older builds.
Cheque your Windows build. To practise that, click Start, type
winver
, and press Enter. A dialog box will open. Look on the 2d line for "Bone Build XXXXX.YYY". If the XXXXX part of that is a number smaller than 17643, you must update Windows at present: go to "Settings → Update & Security → Windows Update → Bank check for updates" and install updates. When finished, runwinver
again to double bank check that the build is 17643 or greater.If you tin can't get a recent build—perchance considering your hardware is a flake older—you lot'll need to install the VM. Y'all could effort these instructions to install WSL on older builds. But, (i) we don't know whether they will work, and (2) y'all still might take unknown troubles installing OPAM.
-
Open Windows PowerShell as Administrator. To do that, click Kickoff, type PowerShell, right click on "Windows PowerShell" (which should exist at the top equally the best match), and click "Run every bit administrator". Click Aye to let changes.
- At the prompt (which is probably something like
PS C:\windows\system32>
), enter the following command:Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
-
If you are prompted to restart, practise so. Otherwise, close PowerShell.
-
Click Get-go, type Microsoft Store, and open the Microsoft Shop app. Click Search, and type Ubuntu. Gyre down to Apps, and choose Ubuntu, which should be the beginning consequence. (Make sure to chose "Ubuntu" non "Ubuntu 16.04 LTS". In theory "Ubuntu 18.04 LTS" would be fine, because that's what "Ubuntu" ought to install anyway.) From the Ubuntu page, click Get. Subsequently the download finishes, click Launch. The install will so finish.
-
You volition exist prompted to create a UNIX username and password. You can use any username and password yous wish. It has no bearing on your Windows username and countersign (though you are complimentary to re-use those). You volition need to call back the password for futurity use.
- You volition at present be inside a terminal at the Bash shell. The prompt will look something similar
You'll desire to make certain re-create-and-paste into the terminal is enabled: Click on the icon on the summit left of the shell window, click Properties, and make sure "Use Ctrl+Shift+C/V as Copy/Paste" is checked. (If you don't see that pick, your Windows build is too erstwhile. Make sure you updated Windows to a new enough build, as described above. Right-click might nonetheless work to paste fifty-fifty if you don't have a new plenty build.) Now Ctrl+Shift+C will copy and Ctrl+Shift+V will paste into the terminal. Notation that yous take to include Shift as part of that keystroke.
- Enter the following command into the shell:
You will be prompted for the UNIX countersign you chose. The command that y'all are running is updating the APT package manager, which is what helps install software inside WSL. The prefix
sudo
means to run the command as the administrator, aka "super user". In other words, do this command every bit super user, hence, "sudo".Pro-tip: Running commands with
sudo
is potentially dangerous and should not exist done lightly. Do not get into the addiction of puttingsudo
in forepart of commands. - Now run this command to upgrade all the APT software packages; it will take awhile. If you are prompted about configuring libssl, just hit Enter to accept the default choices.
- Run this command to install some additional packages:
sudo apt install -y m4 unzip bubblewrap build-essential
-
WSL has its own filesystem that is distinct from the Windows filesystem. Yous can edit Windows files from WSL, merely y'all cannot edit WSL files from Windows. So we need to create a Windows directory in which y'all will store all your 3110 work. Get ahead and do that with the Windows File Explorer wherever yous like. For example, you might create a new binder in your
Documents
called3110
. - Now from the WSL Bash shell, run this command to make your 3110 folder easily accessible from WSL:
ln -s /mnt/c/Users/<windows user proper name>/Documents/3110 ~
Replace
<windows user proper noun>
with any your Windows user proper name is. If you're not sure, go to the Windows Start Menu and typecmd
. A Windows shell will open, and the prompt should existC:\Users\<windows user name>
. If you chose a unlike folder proper name in the previous step, then replaceDocuments/3110
with whatever you chose. You 3110 Windows binder will now exist accessible from your WSL home directory.For more than information about the differences betwixt the Windows and WSL filesystems, and how to work with them, meet this guide.
- Install OPAM past running these commands:
wget https://github.com/ocaml/opam/releases/download/2.0.v/opam-2.0.5-x86_64-linux sudo mv opam-2.0.5-x86_64-linux /usr/local/bin/opam sudo chmod a+10 /usr/local/bin/opam
(You might wonder why nosotros're not installing OPAM through APT. The trouble is that APT has OPAM version ane, not version 2. So nosotros have to manually install OPAM instead of using APT to do it automatically.)
- Continue with the instructions under "OPAM configuration" beneath.
Native installation: OS X
You need a Unix package managing director. There are two popular managers on Mac, MacPorts and Homebrew. The instructions beneath presume MacPorts. Whatever you do, do non install both. They practise not play nicely together.
If yous previously installed one of them, make sure it is in working social club and fully up-to-date before proceeding. With MacPorts, that means running sudo port selfupdate
followed by sudo port upgrade outdated
. If there are whatsoever errors, yous need to resolve them before proceeding. Often the easiest manner to do that is to uninstall the package manager then reinstall it from scratch.
If you're starting from scratch, here's what to practice:
-
Follow the MacPorts install instructions:
- First install Xcode, the Xcode control line tools, and accept the Xcode EULA. The instructions for that are given on the MacPorts install folio linked above.
- Before proceeding with the MacPorts install, break to install XQuartz. Technically this step is optional, just you tin salvage yourself some potential future trouble with OCaml graphics packages past doing it at present.
- Finally, resume post-obit the instructions on the MacPorts install page, and install MacPorts itself.
-
Open a Terminal. Run
sudo port install opam
. -
Continue with the instructions nether "OPAM configuration" below.
Native installation: Linux
-
It's best to use your distribution's package manager to install OPAM. The OPAM installation page has detailed instructions for many popular package managers. Unfortunately, not all distributions make the latest version of OPAM available. If you can't get v2.0.5 through your bundle managing director, we advise that you instead follow the instructions at the top of the OPAM install page to install a binary.
-
Note that in our testing this August, nosotros discovered that OPAM v2.0.3 on Ubuntu has a configuration problems that makes information technology incommunicable to install OCaml 4.08.1. That's why we recommend above getting OPAM v2.0.5 every bit a binary.
-
Continue with the instructions under "OPAM configuration" below.
OPAM configuration
You exercise non demand to follow these instructions if you are using the VM. We have already done them for you.
-
Check your OPAM version by running
opam --version
. That ought to report that you have OPAM version ii, eastward.chiliad.,2.0.5
. If you instead have version 1, east.one thousand.,1.2.2
, you have to fix that before proceeding. Follow the instructions under "Need help?" below. -
If you have ever had OPAM installed before this semester, nosotros highly recommend that yous start fresh instead of trying to upgrade an earlier install. To start fresh, all you have to practice is delete the directory
~/.opam
, or, move information technology to a different location—east.g.,mv ~/.opam ~/.opam.bak
. -
This step varies depending on whether you are running on Windows, or on Bone X or Linux.
On Windows (WSL), run the following control to initialize OPAM:
# Note: do Not prefix this command with sudo opam init --blank -a -y --disable-sandboxing
(We have to disable sandboxing because of an open OPAM result related to WSL. Hopefully that volition be fixed in the future.)
On OS Ten or Linux, run this command:
# Note: do NOT prefix this command with sudo opam init --bare -a -y
- Enter the post-obit commands to switch OPAM to the OCaml 4.08.1 compiler:
# Notation: do Non prefix these commands with sudo opam switch create iv.08.ane ocaml-base-compiler.4.08.one eval $(opam env)
If you become an error nigh 4.08.one not being a known compiler version, try running
opam update
.At present check your compiler version past running
opam switch show
. If that reports annihilation other than4.08.1
, then something has gone wrong; follow the instructions nether "Need assistance?" below. Be aware that OCaml version 4.08 is the simply supported version of the OCaml compiler in CS 3110 this semester. All your code must compile nether that version. - Enter the post-obit commands to install some OPAM packages that will be needed for CS 3110. Make sure to take hold of the entirety of the first line, which is quite long.
# Notation: practice NOT prefix these commands with sudo opam install -y utop ounit qtest yojson lwt lwt_ppx menhir ansiterminal lambda-term merlin ocp-indent user-setup bisect_ppx-ocamlbuild opam user-setup install
-
Close the concluding y'all were in. Open a new terminal. Check that y'all can run OCaml: Run
utop
to launch the OCaml toplevel. Enter3110;;
followed past the Enter key to evaluate the integer 3110. Stop to capeesh how good an integer it is. Then enter#quit;;
or Control-D to exit the toplevel. -
Double check your OPAM environment by downloading this script and running
bash checkenv.sh
from the last in the directory in which the script is saved. If it reports whatever errors, follow the instructions under "Need help?" beneath. - Continue with the instructions below to configure the VS Code editor for OCaml.
VS Code configuration
You do not need to follow these instructions if you are using the VM. Nosotros take already done them for you lot.
The Visual Studio Lawmaking (VS Code) editor is our current recommendation for the all-time OCaml feel in a mod editor. After installing OPAM, and after installing VS Code, you'll need to install some packages inside the editor itself.
-
Download and install VS Lawmaking.
-
Open VS Lawmaking. If you are on Windows (WSL), brand sure to open VS Code by running
lawmaking .
in a WSL terminal, non by double-clicking the desktop icon in Windows. VS Code should automatically recommend that you now install the "Remote WSL" extension. Do that now. -
Go to View → Extensions. Search for "OCaml and Reason IDE". (Annotation: you do non want the extension just named "OCaml"; it is obsolete.) Selection the extension, and click Install. If the "Reload Required" button then appears, click it.
If y'all are on Windows (WSL), you may see that in that location is a "OCaml and Reason IDE - for WSL", but in our testing of these instructions, we establish that extension did not work: so, install the non-WSL version.
Also if you lot are on Windows (WSL), make sure that yous are installing the "OCaml and Reason IDE" extension remotely on WSL, not locally on Windows.
- We recommend tweaking a few editor settings. Open the user settings JSON file by (i) going to View → Command Palette, (two) typing "settings json", and (iii) selecting Open up Settings (JSON). Copy and paste these settings into the window:
{ "editor.tabSize": 2, "editor.rulers": [ 80 ], "editor.formatOnSave": true, }
Relieve the file and close the tab.
Here is a brief explanation of what you lot only changed: A tab size of 2 spaces is fairly standard in the OCaml community. The ruler at cavalcade 80 will aid you not go over the maximum cavalcade length, and you could even ready it to 78 or 72 if you prefer. The
formatOnSave
setting volition cause your code to be run through a tool chosenocp-indent
each time you lot relieve. That tool re-indents your code according to some adequately adept standards, thus will assistance keep your code beautiful. Notation that y'all tin run that tool anytime past right-clicking and selecting "Format Certificate", and that in that location is a shortcut central for it too (which you will see side by side to "Format Certificate"). -
Cheque that the OCaml integration is working. From the control line, blazon
code .
to open up the electric current directory in VS Code. Create a new file namedexam.ml
and relieve it. Try inboundlet x:string = 3110
. VS Code should then (i) suggest some completions while you are typing, (ii) colorize the syntax as you lot type, and (iii) indicate a type mistake with a squiggle under the3110
. Click on the "Problems" pane or hover over the squiggle to run into the mistake. Put double quotes effectually3110
to fix the error.If you lot are on Windows (WSL) and get an error nearly
ocamlmerlin
, there'southward a expert risk that you lot have the file open through Windows, non through WSL. Make sure that you opened VS Code past typingcode .
in the WSL shell, not by double-clicking a.ml
file in the Windows File Explorer. For other means of opening files through WSL, read this documentation.
Need help?
The course staff is happy to help you out with any trouble you might have! You can come up to office hours or postal service on Campuswire. Earlier posting, please read these tips on asking technical questions.
durochermovenciought1948.blogspot.com
Source: http://www.cs.cornell.edu/courses/cs3110/2019fa/install.html
0 Response to "Ocamlmerlin Move It Away and Try Again"
Post a Comment