j0hnsmith / django-pipeline-browserify

MIT License
37 stars 18 forks source link

I get SuspiciousFileOperation #26

Closed pebreo closed 6 years ago

pebreo commented 6 years ago

I am running:

django.core.exceptions.SuspiciousFileOperation: The joined path (/) is located outside of the base path component (/Users/paul/angular-rest/web/web/backend/static)

My settings look like this:

STATICFILES_DIRS = [
    os.path.join(BASE_DIR, "static"),
]
STATIC_ROOT = os.path.join(BASE_DIR, "static/dist")
STATICFILES_STORAGE = 'pipeline.storage.PipelineCachedStorage'
STATICFILES_FINDERS = (
 'django.contrib.staticfiles.finders.FileSystemFinder',
 'django.contrib.staticfiles.finders.AppDirectoriesFinder',
 'pipeline.finders.PipelineFinder',
)

PIPELINE = {
    'PIPELINE_ENABLED': False, 
    'JAVASCRIPT': {
        'browserify':{
            'source_filenames': (
                'js/pong/main.browserify.js'
            ),
            'output_filename': os.path.join(BASE_DIR, "js/app.js")
        }
    },
    'COMPILERS': ('pipeline_browserify.compiler.BrowserifyCompiler', ),
}

PIPELINE['BROWSERIFY_BINARY'] = '/usr/local/bin/browserify'

Someone had this problem in 2013 for django-pipeline but they fixed it here (https://github.com/jazzband/django-pipeline/issues/211). If you have time, can you take a look at it? I'm afraid a lot of the code is way over my head.

For your convenience, I was able to reproduce the issue in this starter project which was created via django-admin startproject myproject. I placed the project (along with the sqlite3 db) here:

https://github.com/pebreo/dj18-browserify-issue

naitian commented 6 years ago

Super late, and not the maintainer, but I figured I'd answer the question because I just had this problem last night.

You're missing a comma after 'js/pong/main.browserify.js'.

Since source_filenames should be a tuple, there needs to be a comma even after the first item. Otherwise, pipeline will mistakenly read source_filenames as a string instead of a tuple, and (I'm assuming) iterate through every character of 'js/pong/main.browserify.js' as if it were a separate path.

Zeeerooo commented 5 years ago

Thanks @naitian !

bellydrum commented 5 years ago

Thank you so much @naitian

diegueus9 commented 4 years ago

@naitian you're a lifesaver, sir!