Closed tato closed 3 years ago
I think I just needed to run pub get
inside the tool/ directory. I'll see myself out.
I'm having the same issue, except that I can't run any of the tests, even with clox/jlox. Could you elaborate on the pub get thing please? Is pub a tool you have to install?
Is pub a tool you have to install?
If you have installed the Dart SDK, it will include pub. pub
used to be a separate command, but now it's baked into the main dart
command line executable so you should run:
$ dart pub get
From within the tools
directory.
I'd like to provide a solution here as I ran into the same issue today. In my case, my Dart version was 3.0.5 (latest stable as of 06/29/23) which supports null safety. In craftinginterpreters/tool/pubspec.yaml
, the SDK version constraint is set to >2.11.0 <3.0.0
. What this means is that your Dart SDK must be within that version constraint. So, in short, in order for dart pub get
to properly install the package dependencies defined in pubspec.yaml
, you must use an archived Dart SDK version. I used 2.12.0(stable) and that has worked fine with the Makefile. In order to get 2.12.0, first remove your current Dart SDK, mine was in /usr/bin/dart
but you can run which dart
to find yours. Then run the following commands if you are on Linux (If not on Linux, try to find out what to do here):
$ wget https://storage.googleapis.com/dart-archive/channels/stable/release/2.12.0/sdk/dartsdk-linux-x64-release.zip
$ unzip dartsdk-linux-x64-release.zip
$ sudo mv dart-sdk /usr/bin
$ echo 'export PATH="$PATH:/usr/bin/dart-sdk/bin"' >> ~/.bashrc
Hope this helps! Side note: If anyone at Google is looking for a passionate engineer, I'd love to interview. Also @munificent thank you for this lovely book and illustrations.
Sorry if this was pointed out in a previous issue, or if it is too unrelated to the book itself.
The readme shows a way to use the existing test suite to test our own implementation of lox, with a command like
I installed the dart-sdk, and when I run that command, dart complains about missing packages.
I'm not familiar at all with dart, so this could easily be my own mistake, but I figured I would ask in case someone else runs into the same situation. Is this caused by being on Windows? Maybe I'm using a different, incompatible dart version [1]? Or is there a step I didn't follow?
[1] Dart SDK version: 2.13.4 (stable) (Wed Jun 23 13:08:41 2021 +0200) on "windows_x64"