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 test reproducing gh10254 #10255

Merged
merged 1 commit into from
Mar 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
Demonstrate that you can't use a relative path referring outside the workspace
in the pin stanza:

$ . ../helpers.sh

Make a package containing a library:
$ mkdir foo
$ cat > foo/dune-workspace <<EOF
> (lang dune 3.14)
> EOF
$ cat > foo/dune-project <<EOF
> (lang dune 3.14)
> (package
> (name foo))
> EOF
$ cat > foo/dune <<EOF
> (library
> (public_name foo))
> EOF
$ cat > foo/foo.ml <<EOF
> let foo = "foo"
> EOF

Make a second package depending on the first via a pin:
$ mkdir bar
$ cd bar
$ mkrepo
$ add_mock_repo_if_needed
$ cat > dune-project <<EOF
> (lang dune 3.14)
> (pin
> (url file://$PWD/../foo)
> (package (name foo)))
> (package
> (name bar)
> (depends foo))
> EOF
$ cat > dune <<EOF
> (executable
> (public_name bar)
> (libraries foo))
> EOF
$ cat > bar.ml <<EOF
> let () = print_endline Foo.foo
> EOF

Lock and build the second package to demonstrate that everything works so far:
$ dune pkg lock
Solution for dune.lock:
- foo.dev
$ dune exec ./bar.exe
foo

Now change the pin to use a relative path:
$ cat > dune-project <<EOF
> (lang dune 3.14)
> (pin
> (url file://../foo)
> (package (name foo)))
> (package
> (name bar)
> (depends foo))
> EOF

Solving the project now results in an error, though it's still possible to build the project:
$ dune clean
$ dune pkg lock
Error: path outside the workspace: ../foo from .
[1]
$ dune exec ./bar.exe
foo
Loading