Skip to content

Do not follow symlinks when looking for the stdlib files.#956

Open
vitor1001 wants to merge 1 commit intoMiniZinc:developfrom
vitor1001:no_symlinks
Open

Do not follow symlinks when looking for the stdlib files.#956
vitor1001 wants to merge 1 commit intoMiniZinc:developfrom
vitor1001:no_symlinks

Conversation

@vitor1001
Copy link
Contributor

This aligns MiniZinc with the standard behavior of *nix binaries that when a tool expects some directory hierarchy, that must match the reality before following any eventual symlinks, not after.

In particular, the Bazel build system uses a lot of symlinks, making the behavior before this CL particularly confusing.

This aligns MiniZinc with the standard behavior of *nix binaries that when a tool expects some directory hierarchy, that must match the reality before following any eventual symlinks, not after.

In particular, the Bazel build system uses a lot of symlinks, making the behavior before this CL particularly confusing.
@vitor1001 vitor1001 changed the base branch from master to develop September 29, 2025 15:34
@guidotack
Copy link
Member

We're considering the switch to C++17, which would enable the use of std::filesystem::path::lexically_normal (among other filesystem functions). As far as I can see, that would also fix this issue, and it would have the added bonus of being platform independent (we currently need Windows-specific code here).
It would be great to hear if that would solve the issue for you, and whether you can you see any other downsides of this approach.

@vitor1001
Copy link
Contributor Author

Hi Guido!

Yes, a much simpler implementation using std::filesystem works for us. Here is what I tested:

std::string file_path(const std::string& filename, const std::string& basePath) {
  std::filesystem::path path(filename);
  if (!basePath.empty() && !path.is_absolute()) {
    path = std::filesystem::path(basePath) / path;
  }

  if (!path.is_absolute()) {
    path = std::filesystem::current_path() / path;
  }

  return path.lexically_normal();
}

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

Successfully merging this pull request may close these issues.

2 participants