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

--project=@script is broken or NEWS entry is incorrect (Julia 1.11.0-rc3) #55606

Open
StevenWhitaker opened this issue Aug 27, 2024 · 5 comments
Labels
bug Indicates an unexpected problem or unintended behavior duplicate Indicates similar issues or pull requests

Comments

@StevenWhitaker
Copy link

StevenWhitaker commented Aug 27, 2024

This issue has two parts.

EDIT: Note that Issue 1 is a duplicate of #55069, but Issue 2 is not.

Issue 1

The following NEWS entry is incorrect:

If no path is given after (i.e. --project=@script) then (like --project=@.) the directory and its parents are searched for a Project.toml

In particular, it appears --project=@script has the same behavior as --project=@., which doesn't seem intended (though maybe I'm reading the NEWS entry incorrectly).

MWE

In <current_directory>/script_test/test.jl:

println("Current directory: ", pwd())
println("Active project: ", Base.active_project())

Result:

$ julia +1.11 --project=@script script_test/test.jl
Current directory: <current_directory>
Active project: <current_directory>/Project.toml # Expected: <current_directory>/script_test/Project.toml

See #55069 for more details.

Issue 2

The previous part of the same NEWS entry is also incorrect:

The --project argument now accepts @script to give a path to a directory with a Project.toml relative to the passed script file. --project=@script/foo for the foo subdirectory.

In particular, --project=@script/script_test activates /script_test/Project.toml. (Note this is an absolute path, not a relative path!)

MWE

Same test.jl file as above.

Result:

$ julia +1.11 --project=@script/foo script_test/test.jl
Current directory: <current_directory>
Active project: /script_test/Project.toml # Expected: <current_directory>/script_test/foo/Project.toml
@tecosaur tecosaur added bug Indicates an unexpected problem or unintended behavior duplicate Indicates similar issues or pull requests labels Oct 21, 2024
@tecosaur
Copy link
Contributor

Thanks for reporting! Let's focus on #55069 though 🙂

@StevenWhitaker
Copy link
Author

@tecosaur I agree that Issue 1 above is a dupe of #55069. However, #55069 doesn't mention anything about the --project=@script/sub_dir functionality (what I call Issue 2 above). So this issue isn't a complete duplicate. Would it be better to open a new issue with just Issue 2 above?

@tecosaur
Copy link
Contributor

At a glance, I suspect that Issue 2 might be solved by fixing Issue 1 (if the base path is determined incorrectly, paths relative to it will be incorrect too).

@StevenWhitaker
Copy link
Author

I am slightly doubtful the same fix will apply to both issues because in Issue 2 above an absolute path somehow gets introduced. In other words, if Issue 2 did just depend on Issue 1 getting the correct base path, then the Issue 2 result should be

Active project: <current_directory>/foo/Project.toml

which isn't the case, as I report above (foo doesn't even show up in the active project).

But I guess we'll see.

@tecosaur
Copy link
Contributor

Ah right, I think I just missed that nuance in a skim-read. I'll reopen the issue 🙂

@tecosaur tecosaur reopened this Oct 21, 2024
awadell1 added a commit to awadell1/julia that referenced this issue Oct 26, 2024
awadell1 added a commit to awadell1/julia that referenced this issue Oct 26, 2024
awadell1 added a commit to awadell1/julia that referenced this issue Oct 26, 2024
awadell1 added a commit to awadell1/julia that referenced this issue Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior duplicate Indicates similar issues or pull requests
Projects
None yet
Development

No branches or pull requests

2 participants