Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a "from scratch" section to the "getting started" page #85

Open
mlms13 opened this issue Jun 18, 2023 · 3 comments
Open

Add a "from scratch" section to the "getting started" page #85

mlms13 opened this issue Jun 18, 2023 · 3 comments

Comments

@mlms13
Copy link

mlms13 commented Jun 18, 2023

Currently, the Getting Started docs highlight the [template]( template, which is definitely the easiest way for most people to jump in, but personally I like to set up new projects by hand because I feel like it helps me get more familiar with how the ecosystem's tools fit together. Especially as someone coming from Bucklescript, I'm less familiar with how the opam and dune pieces fit together, and I'd like more hands-on experience getting a project set up with those tools.

Some specific things I'm confused about:

  • opam installs dune, then I can use dune init to create a project... which will likely have its own opam switch? Do I first need to create an opam switch with the version of dune I want to use inside the new project?

...wait, maybe that's the only thing I'm confused about. 😆 I'll keep working through this and let you know if there's anything else that confuses me.

@jchavarri
Copy link
Member

dune init only creates a project layout with files like dune, some ml OCaml modules etc but it does not create a switch. Actually Dune will never do anything related to fetching or downloading anything related to the toolchain or dependencies (this is subject to change after this RFC is implemented). It relies on opam creating a switch previously and downloading the dependencies to have the toolchain available.

So, the first thing to do for a new project is always creating the opam switch. Once that is done you can proceed to install the dependencies for the project, and Dune is most probably the first dependency one wants to install.

Btw if you want to take a stab at the "from scratch" section I encourage you to do so, you are probably one of the best positioned to do so! 🤗

@mlms13
Copy link
Author

mlms13 commented Jun 19, 2023

I'm more than happy to take a shot at writing a small "from scratch" section. I think I got a from-scratch setup working yesterday, but before I write things down, I'd love to get feedback on this general outline from people who actually know what they're doing. 😁

  • using a global opam switch that has dune 3.8 or greater installed (is this part true?) run dune init to create your new project
  • in the new project directory, create an opam switch for the project
  • add and install dependencies (especially melange, optionally reason, probably some lsp stuff)
  • configure a dune file with some melange.emit rules, etc, probably lots of linking to other existing docs and examples in the template when we get to this point

The first two steps in particular are the ones that could use some guidance, I think. Like, is it correct that you need a global opam + global dune first, so that you can init the project and then make the project switch?

@jchavarri
Copy link
Member

There's no need to use the global switch, an opam local switch can be installed with opam switch create . 4.14.1 and then opam install dune to get Dune and be able to run dune init.

In other words:

in the new project directory, create an opam switch for the project

This can be the first step.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants