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

Make dub run --root=x default app CWD in dub CWD #2583

Merged
merged 1 commit into from Feb 10, 2023

Conversation

WebFreak001
Copy link
Member

Fix #2582

cc @Geod24

@ibuclaw should I target this on stable, so we can make a hotfix release of DUB with this fix? Last release contained a regression / change in behavior as described in that issue, which this PR fixes and tests.

Note: I'm not fully confident in this solution until the CI has passed, but new tests pass, I tried some CWD tests and general usage seems to work.

@ibuclaw
Copy link
Member

ibuclaw commented Feb 9, 2023

@WebFreak001 bug and regression fixes should always target stable really.

@WebFreak001 WebFreak001 changed the base branch from master to stable February 9, 2023 10:17
@WebFreak001
Copy link
Member Author

targetting stable, added changelog entry

@WebFreak001
Copy link
Member Author

WebFreak001 commented Feb 9, 2023

forgot to push the actual fix in the rebase, but CI seems to pass? Need to fix my test in this case

Seems I messed up in the rebase entirely, also forgot to push my test script, I don't know what happened there. Everything should be fixed up now.

Copy link
Member

@Geod24 Geod24 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So does workingDirectory: "." give the right (respects --root) or wrong behavior ?

Comment on lines +1214 to +1215
// legacy compatibility, default working directory is always CWD
gensettings.overrideToolWorkingDirectory = getWorkingDirectory();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think --root should be respected (in the long run). So reverting the behavior is just to avoid breaking code. What is our path forward ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's sane to keep it like this forever.

Using workingDirectory "." you get the behavior that workingDirectory == package directory, which you had with the breaking behavior here. So I think it's fine really

Comment on lines 1 to 14
Fixed regression with `dub --root=x` from last release

Since last release builds via the DUB API rely on the package path or an
explicitly set working directory, instead of the apps working directory. However
in the `dub` command line tool the previous behavior was when using
`dub run --root=path`, the built app that is being run would be run from dubs
current cwd, unless `workingDirectory` is specified in the recipe. Now since the
last release this changed to the package directory (e.g. like defaulting
`"workingDirectory": "."` in dub.json), which is considered a breaking change /
regression.

So this release reverts back the behavior that was accidentally changed, so that
the `dub` CLI working directory is always being used as program cwd when no
working directory is set in the package recipe.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted v1.31.0 working directory change when using `dub run --root=<value>`

dub < v1.31.0 would run applications in the working directory it was invoked in, ignoring the `--root` argument.
In v1.31.0, `dub` started to respect the `--root` argument and run programs in the requested directory.
While desirable, this change was not intended, and has now been reverted. It will be re-introduced as part of a major version upgrade.

Let me know if that works for you. I tried to rephrase the text keeping the important informations you already put in, but doing it more succinctly.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have adjusted it to mostly that, but omitted that it would be re-introduced. I think the workingDirectory: "." setting is a good universal solution to cover all use cases. (those who want the dub cwd as part of some CI run and those who want to control it to their package)

@Geod24
Copy link
Member

Geod24 commented Feb 9, 2023

Let's focus the discussions as to whether we want to keep this behavior in #2582 :)

@WebFreak001
Copy link
Member Author

should we merge this then?

@ibuclaw I don't know how the release cycle on DUB works and you have usually done it in the past, would we just tag a new minor release with this fix?

@ibuclaw
Copy link
Member

ibuclaw commented Feb 9, 2023

should we merge this then?

@ibuclaw I don't know how the release cycle on DUB works and you have usually done it in the past, would we just tag a new minor release with this fix?

I'll tag the current head of stable. How soon should the fix go out?

@WebFreak001
Copy link
Member Author

WebFreak001 commented Feb 9, 2023

it's a regression fix, so as soon as possible would be nice. I know it breaks the CI in serve-d as well, but it's an easy workaround for me. It may not be such an easy fix for other people and in general not a nice experience if you suddenly need to change your tooling code that has worked for years.

Gonna merge this now then. can't merge this myself

@WebFreak001 WebFreak001 enabled auto-merge (rebase) February 9, 2023 21:35
@Geod24 Geod24 merged commit 4b42360 into dlang:stable Feb 10, 2023
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

Successfully merging this pull request may close these issues.

App's CWD changed when running DUB with --root=xyz
3 participants