Skip to content

Commit bd92ca8

Browse files
Do not try to override existing lib path in dependency (#599)
1 parent 44a2330 commit bd92ca8

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/package.cr

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,17 +66,23 @@ module Shards
6666
# link the project's lib path as the shard's lib path, so the dependency
6767
# can access transitive dependencies:
6868
unless resolver.is_a?(PathResolver)
69-
lib_path = File.join(install_path, Shards::INSTALL_DIR)
70-
Log.debug { "Link #{Shards.install_path} to #{lib_path}" }
71-
Dir.mkdir_p(File.dirname(lib_path))
72-
target = File.join(Path.new(Shards::INSTALL_DIR).parts.map { ".." })
73-
File.symlink(target, lib_path)
69+
install_lib_path
7470
end
7571

7672
Shards.info.installed[name] = self
7773
Shards.info.save
7874
end
7975

76+
private def install_lib_path
77+
lib_path = File.join(install_path, Shards::INSTALL_DIR)
78+
return if File.exists?(lib_path)
79+
80+
Log.debug { "Link #{Shards.install_path} to #{lib_path}" }
81+
Dir.mkdir_p(File.dirname(lib_path))
82+
target = File.join(Path.new(Shards::INSTALL_DIR).parts.map { ".." })
83+
File.symlink(target, lib_path)
84+
end
85+
8086
protected def cleanup_install_directory
8187
Log.debug { "rm -rf #{Process.quote(install_path)}" }
8288
Shards::Helpers.rm_rf(install_path)

0 commit comments

Comments
 (0)