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

Generated paths point to root of my HDD #25

Closed
vorg opened this issue Nov 8, 2014 · 12 comments
Closed

Generated paths point to root of my HDD #25

vorg opened this issue Nov 8, 2014 · 12 comments

Comments

@vorg
Copy link

vorg commented Nov 8, 2014

I'm trying to build my project by following this tutorial and I get this error:

{ [Error: EACCES, mkdir '/marcinignac-com'] errno: 3, code: 'EACCES', path: '/marcinignac-com' }

Obviously node doesn't have access to crate folders in root of my HDD

My project tree

com-marcinignac
├── build
├── build.js
├── package.json
├── src
│   ├── css
│   │   └── main.css
│   ├── index.md
│   └── projects
│       ├── cindermedusae
│       │   ├── cindermedusae.md
│       │   └── img
│       │       └── cindermedusae_01.jpg
│       ├── fibers
│       │   └── fibers.md
│       └── ucc-organism
│           └── ucc-organism.md
└── templates
    ├── index.html
    ├── partials
    │   ├── footer.html
    │   └── header.html
    └── post.html

Used modules

    "handlebars": "^2.0.0",
    "metalsmith": "^1.0.1",
    "metalsmith-collections": "^0.6.0",
    "metalsmith-drafts": "0.0.1",
    "metalsmith-markdown": "^0.2.1",
    "metalsmith-permalinks": "^0.3.2",
    "metalsmith-templates": "^0.6.0",
    "metalsmith-watch": "^0.1.1"

Metalsmith config

metalsmith(__dirname)
  .use(collections({
    projects: {
      pattern: 'projects/**/*.md'
    }
  }))
  .use(markdown())
  .use(permalinks({
    pattern: ':collection/:title',
    relative: false
  }))
  .use(templates('handlebars'))
  .destination('./build')
  .build(function(err){
    if (err) throw err;
  });
@vorg
Copy link
Author

vorg commented Nov 8, 2014

The project above build successfully with.

metalsmith-permalinks 0.4.0
metalsmith-collections 0.4.0 & 0.5.1

@brandenbyers
Copy link

Running into a similar issue. Recently started getting this the following error. No errors when I remove metalsmith-permalinks.

Error: EACCES, open '/about/index.html'

Why is permalinks attempting to access root?

@brandenbyers
Copy link

The pattern appears to be my problem. Do you still get errors if you change the pattern from

    .use(permalinks({
        pattern: ':collection/:title',
        relative: false
    }))

to this:

    .use(permalinks({
        pattern: ':title',
        relative: false
    }))

I don't get any build errors when I remove collection from the pattern. If not, is the problem metalsmith-permalinks or metalsmith-collections?

@brandenbyers
Copy link

Looks like my issue might have been different after all. Just in case it helps: I had one of my collections patterns prefixed with a "/" and that was causing the root issue. Changed this:

    .use(collections({
        pages: {
            pattern: '/content/pages/*.md'

to this and no more errors:

    .use(collections({
        pages: {
            pattern: 'content/pages/*.md'

@nickbuddendotcom
Copy link

@brndnb I'm having the same issue, Error: EACCES, open '/about/index.html'.

var Metalsmith  = require('metalsmith');
var markdown    = require('metalsmith-markdown');
var templates   = require('metalsmith-templates');
var collections = require('metalsmith-collections');
var permalinks  = require('metalsmith-permalinks');
var stylus      = require('metalsmith-stylus');
var watch       = require('metalsmith-watch');
var ignore      = require('metalsmith-ignore');

Metalsmith(__dirname)
  .use(ignore([
    'drafts/*',
    '.DS_Store'
  ]))
  // .use(watch())
  .use(collections({
    pages: {
      pattern: 'content/pages/*.md'
    }
  }))
  .use(markdown())
  .use(permalinks({
    pattern: ':collection/:title'
  }))
  .use(templates('jade'))
  .use(stylus())
  .destination('./build')
  .build(function(err, files) {
    if (err) { throw err; }
  });

Unfortunately no prefixed slash for me.

@fengtality
Copy link

i had the same issue. Adding permalink: false as described in #22 fixed it.

@skyturtleio
Copy link

I have a similar folder structure as the tutorial mentioned by @vorg. I had the same issue when trying to build but it was only with the index.md. The content/pages/ and /content/posts/ directories had no problems during build. Removing the prefix slash and adding permalink: false to the YAML front matter of my index.md as mentioned above fixed the issue.

@mdvorscak
Copy link
Contributor

I have the same exact issue, and after a bit of debugging I've determined the cause:

The code from the tutorial is:

Metalsmith(__dirname)
    .use(collections({
             pages : {
                 pattern : 'content/pages/*.md'
             },
             posts : {
                 pattern : 'content/posts/*.md',
                 sortBy  : 'date',
                 reverse : true
             }
         }))
    .use(permalinks({
             pattern : ':collection/:title'
         }))
...

The issue was seen in the file blogRoot/src/index.md,since this file didn't match a 'collection' pattern the permalink was '/home/index.html' (the root of the file system)

Adding permalink: false to the (front-matter of the) offending files does fix the issue.

However, I think this issue should still be addressed in this plugin in a more flexible way this pull request attempts to fix the issue. But in my opinion, it too tightly couples different modules that don't need to know about each other.

Maybe a better solution would be to do something like (just a proposed solution not actual working code):

  .use(permalinks({
             pattern : ':collection/:title',
            ignore: function(patternPart){
                return typeof patternPart === 'undefined';
            }
         }))

where the ignore function would also remove any following slashes.

@eddieh
Copy link

eddieh commented Jun 24, 2015

If this is happening to you after adding permalink: false, try moving your .use(collections()). For me, it works when it is the first.

@donofkarma
Copy link

Just had this issue myself, found it to be a leading / in the pattern.

@jarodtaylor
Copy link

Is the solution still to add the permalink:false to the front-matter?

@nikmartin
Copy link

.use(permalinks({
    relative: false,
    pattern: './:collection/:title' \\ <<<< note the './' 
  }))

woodyrew added a commit that referenced this issue Jul 21, 2018
Fix #25, all falsy pattern values and empty arrays are now treated the same
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

No branches or pull requests

10 participants