Skip to content

Commit

Permalink
builtins.readFile: Put the references of the file, not those needed t…
Browse files Browse the repository at this point in the history
…o realize the file, into the context
  • Loading branch information
shlevy committed Jan 10, 2017
1 parent 7adb986 commit 451c223
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/libexpr/primops.cc
Expand Up @@ -779,6 +779,9 @@ static void prim_readFile(EvalState & state, const Pos & pos, Value * * args, Va
string s = readFile(state.checkSourcePath(path));
if (s.find((char) 0) != string::npos)
throw Error(format("the contents of the file ‘%1%’ cannot be represented as a Nix string") % path);
context = state.store->isInStore(path) ?
state.store->queryPathInfo(state.store->toStorePath(path))->references :
PathSet{};
mkString(v, s.c_str(), context);
}

Expand Down

5 comments on commit 451c223

@shlevy
Copy link
Member Author

@shlevy shlevy commented on 451c223 Jan 10, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@edolstra
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shlevy
Copy link
Member Author

@shlevy shlevy commented on 451c223 Jan 17, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, that works locally...

@shlevy
Copy link
Member Author

@shlevy shlevy commented on 451c223 Jan 17, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm really confused as to how that could be happening... the readFile above works, so the path must be valid, unless somehow we're accidentally referencing an invalid path and reading from it?

@shlevy
Copy link
Member Author

@shlevy shlevy commented on 451c223 Jan 17, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can nix query validity from within the chroot?

Please sign in to comment.