Skip to content

Commit

Permalink
Do not try to override existing lib path in dependency (crystal-lang#599
Browse files Browse the repository at this point in the history
)
  • Loading branch information
straight-shoota authored and kojix2 committed Dec 28, 2023
1 parent 54988d5 commit 1b9f06c
Showing 1 changed file with 11 additions and 5 deletions.
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

0 comments on commit 1b9f06c

Please sign in to comment.