GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Trailing slash consistency between __dirname and os.tmpdir() · Issue #715 · nodejs/node

Trailing slash consistency between __dirname and os.tmpdir() #715

New issue
Copy link
New issue
Copy link
Closed
Closed
Trailing slash consistency between __dirname and os.tmpdir()#715
Copy link
Labels
osIssues and PRs related to the os subsystem.

Description

@hacksparrow
hacksparrow
opened on Feb 4, 2015
Issue body actions
console.log(os.tmpdir()) // trailing slash
console.log(__dirname) // no trailing slash

Is there a good reason why os.tmpdir() ends with a trailing slash, while __dirname does not? If there is none, it might make sense to make the return values consistent.

Activity

  1. micnic commented on Feb 4, 2015

    @micnic
    micnic
    on Feb 4, 2015
    Contributor
    More actions

    it may be that this is a platform specific issue, for me they are both without trailing slash, what operating system are you using?

  2. cjihrig commented on Feb 4, 2015

    @cjihrig
    cjihrig
    on Feb 4, 2015
    Contributor
    More actions

    os.tmpdir() comes directly from environment variables. __dirname uses path.dirname(), which strips trailing slashes.

  3. hacksparrow commented on Feb 4, 2015

    @hacksparrow
    hacksparrow
    on Feb 4, 2015
    Author
    More actions

    Mac OS.

  4. tellnes commented on Feb 4, 2015

    @tellnes
    tellnes
    on Feb 4, 2015
    Contributor
    More actions

    Maybe we should make os.tmpdir() strip trailing slashes?

  5. cjihrig commented on Feb 4, 2015

    @cjihrig
    cjihrig
    on Feb 4, 2015
    Contributor
    More actions

    It would be nice to be consistent, but it could potentially break existing code.

  6. tellnes commented on Feb 4, 2015

    @tellnes
    tellnes
    on Feb 4, 2015
    Contributor
    More actions

    Yes it will probably break some existing code, but I still see this as a bug.

  7. cjihrig commented on Feb 4, 2015

    @cjihrig
    cjihrig
    on Feb 4, 2015
    Contributor
    More actions

    I would be OK with this for a major version bump, but I'd like to hear what others think.

  8. brendanashworth
    added
    osIssues and PRs related to the os subsystem.
    on Feb 5, 2015
  9. hacksparrow commented on Feb 6, 2015

    @hacksparrow
    hacksparrow
    on Feb 6, 2015
    Author
    More actions

    Right now I am getting through by adding a mandatory '/' everywhere I suspect the slash may or may not be found, and using path.normalize(). But it is an inelegant solution.

    Probably iojs should work on normalizing the trailing slash to provide for a consistent interface. It is a pain when something works on Mac and fails on Linux, and vice versa.

  10. micnic commented on Feb 6, 2015

    @micnic
    micnic
    on Feb 6, 2015
    Contributor
    More actions

    I was looking on Github for modules which use os.tmpdir() and most of them use path methods to deal with it, only about 4 modules out of ~50 that I found were using raw string concatenation which can lead to some issues

  11. tellnes commented on Feb 6, 2015

    @tellnes
    tellnes
    on Feb 6, 2015
    Contributor
    More actions

    This is a quick fix in io.js and a quick fix in those modules if they break. I'll go ahead and create a pull request and then the only thing left is to choose whether to merge or not.

  12. tellnes
    added a commit that references this issue on Mar 21, 2015

    os: remove trailing slash from os.tmpdir()

    bb97b70
  13. tellnes commented on Mar 22, 2015

    @tellnes
    tellnes
    on Mar 22, 2015
    Contributor
    More actions

    Landed in next branch as bb97b70

  14. tellnes
    closed this as completedon Mar 22, 2015
  15. tellnes
    added a commit that references this issue on Apr 28, 2015

    os: remove trailing slash from os.tmpdir()

    b57cc51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    osIssues and PRs related to the os subsystem.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.