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

Relative path to the build directory is treated like absolute #128

Open
ClaudiuCreanga opened this issue Aug 30, 2018 · 5 comments
Open
Labels

Comments

@ClaudiuCreanga
Copy link

When using the command line:
python manage.py build report.views.RenderView --build-dir ./build
bakery tries to create the top level directory /build and fails because of permissions.
fs.errors.PermissionDenied: permission denied mkdir: ./build: No such file or directory

It should instead create it in the current directory because there is a dot in front.

Is this by design?

It is not something that one cannot get around, but when using singularity and some workflow systems (nextflow), using absolute paths may become messy, as you're working with isolated directories.

@palewire
Copy link
Owner

palewire commented Sep 1, 2018

Interesting. The code that makes it happen is right here:

    def init_build_dir(self):
        """
        Clear out the build directory and create a new one.
        """
        # Destroy the build directory, if it exists
        logger.debug("Initializing %s" % self.build_dir)
        if self.verbosity > 1:
            self.stdout.write("Initializing build directory")
        if self.fs.exists(self.build_dir):
            self.fs.removetree(self.build_dir)
        # Then recreate it from scratch
        self.fs.makedirs(self.build_dir)

Anything look off?

@ClaudiuCreanga
Copy link
Author

ClaudiuCreanga commented Sep 3, 2018

That will always assume a full path.
To care for relative paths, if it is something that you want, we can use these:

os.path.realpath can handle absolute and relative paths
os.path.expanduser will handle cases involving "~"

So something like this:
self.fs.makedirs(os.path.realpath(os.path.expanduser("self.build_dir")))

@palewire
Copy link
Owner

palewire commented Sep 3, 2018

Okay. I'm open to a change along these lines, but I'd like to add some testing to verify its working now and in the future. What different path inputs could you imagine we should test for?

@ClaudiuCreanga
Copy link
Author

ClaudiuCreanga commented Sep 4, 2018

I would think these:

/directory
/directory/directory

~/
~/directory

./
./directory

../
../directory
../../directory

a symlink directory

Can't think of anything else.

@palewire
Copy link
Owner

palewire commented Dec 5, 2018

@ClaudiuCreanga, would you be interested in developing a patch to solve this problem?

@palewire palewire added the bug label Dec 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants