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

fix: setup now sets migrations dir as relative path when possible #4439

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

the-solid-box
Copy link

fixes #4436

@the-solid-box
Copy link
Author

I do not know where macos differs when it comes to the second test I have included. Since I do not have the means to run tests on macos, and I do not wish to pollute this PR with hypothese-commits on what could be the fix, I'd appreciate if someone can enlighten me :)

@weiznich
Copy link
Member

Thanks for opening this PR. These errors look strange. Unfortunately I do not have access to any other macos machine than the CI runners and I cannot reproduce the issue locally so its hard for me to tell what's wrong here.

On MacOS, the project directory (created by tempdir), is in /var/folders/...

This /var directory is a symlink to /private/var

In the function create_config_file(), the 'current_path' parameter used in the function convert_absolute_path_to_relative() is defined by calling find_project_root() which return a path in /private/var/...

In the test "setup_writes_migration_dir_as_relative_path", when the function convert_absolute_path_to_relative() is called, target_path and current_path are both in /private/var and everything is fine

the test "setup_writes_migration_dir_as_arg_as_relative_path" uses p.directory(), which return a path in /var
So when the function convert_absolute_path_to_relative() is called, target_path is in /var/ but current_path is in /private/var

The result of this is that the diesel.toml file generated contains :

dir = "../../../../../../../var/folders/by/lfy0tf8939qflt_lsmzt0mzr0000gn/T/setup_writes_migration_dir_as_arg_as_relative_pathMYasaL/foo"

and that value is not what we expect ;)

So, I added a call to canonicalize() after p.directory_path() so that the path is resolved to /private/var/... => the tests pass
@gcavelier
Copy link

@the-solid-box, I submitted a PR on your repo to fix the tests on MacOS

the-solid-box#1

@the-solid-box
Copy link
Author

@the-solid-box, I submitted a PR on your repo to fix the tests on MacOS

the-solid-box#1

Merged, let's see if the CI still complains!

@the-solid-box
Copy link
Author

Well, looks like windows isn't liking it now... Luckily I do have a windows machine, I'll have a look when I can. Might just write two tests, one for macos, one for windows and linux. Thanks for the help @gcavelier

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.

Setup should not use an absolute path to set the migrations_directory 'dir' field of diesel.toml
3 participants