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

Do not try to override existing lib path in dependency #599

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions src/package.cr
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,23 @@ module Shards
# link the project's lib path as the shard's lib path, so the dependency
# can access transitive dependencies:
unless resolver.is_a?(PathResolver)
lib_path = File.join(install_path, Shards::INSTALL_DIR)
Log.debug { "Link #{Shards.install_path} to #{lib_path}" }
Dir.mkdir_p(File.dirname(lib_path))
target = File.join(Path.new(Shards::INSTALL_DIR).parts.map { ".." })
File.symlink(target, lib_path)
install_lib_path
end

Shards.info.installed[name] = self
Shards.info.save
end

private def install_lib_path
lib_path = File.join(install_path, Shards::INSTALL_DIR)
return if File.exists?(lib_path)

Log.debug { "Link #{Shards.install_path} to #{lib_path}" }
Dir.mkdir_p(File.dirname(lib_path))
target = File.join(Path.new(Shards::INSTALL_DIR).parts.map { ".." })
File.symlink(target, lib_path)
end

protected def cleanup_install_directory
Log.debug { "rm -rf #{Process.quote(install_path)}" }
Shards::Helpers.rm_rf(install_path)
Expand Down
Loading