@@ -79,6 +79,10 @@ defmodule Mix.Sync.Lock do
79
79
This function can also be called if this process already has the
80
80
lock. In such case the function is executed immediately.
81
81
82
+ When the `MIX_OS_CONCURRENCY_LOCK` environment variable is set to
83
+ a falsy value, the lock is ignored and the function is executed
84
+ immediately.
85
+
82
86
## Options
83
87
84
88
* `:on_taken` - a one-arity function called if the lock is held
@@ -96,9 +100,9 @@ defmodule Mix.Sync.Lock do
96
100
path = Path . join ( [ System . tmp_dir! ( ) , "mix_lock" , hash ] )
97
101
98
102
pdict_key = { __MODULE__ , path }
99
- has_lock? = Process . get ( pdict_key )
103
+ has_lock? = Process . get ( pdict_key , false )
100
104
101
- if has_lock? do
105
+ if has_lock? or lock_disabled? ( ) do
102
106
fun . ( )
103
107
else
104
108
lock = lock ( path , opts [ :on_taken ] )
@@ -115,6 +119,8 @@ defmodule Mix.Sync.Lock do
115
119
end
116
120
end
117
121
122
+ defp lock_disabled? ( ) , do: System . get_env ( "MIX_OS_CONCURRENCY_LOCK" ) in ~w( 0 false)
123
+
118
124
defp lock ( path , on_taken ) do
119
125
File . mkdir_p! ( path )
120
126
@@ -198,11 +204,12 @@ defmodule Mix.Sync.Lock do
198
204
:invalidated
199
205
200
206
{ :error , reason } ->
201
- raise File.LinkError ,
202
- reason: reason ,
203
- action: "create hard link" ,
204
- existing: port_path ,
205
- new: lock_path
207
+ Mix . raise ( """
208
+ could not create hard link from #{ port_path } to "#{ lock_path } : #{ :file . format_error ( reason ) } .
209
+
210
+ Hard link support is required for Mix compilation locking. If your system \
211
+ does not support hard links, set MIX_OS_CONCURRENCY_LOCK=0\
212
+ """ )
206
213
end
207
214
end
208
215
0 commit comments