@@ -277,20 +277,33 @@ def plugin(name, *args)
277277      version  =  args  || [ ">= 0" ] 
278278
279279      # We don't care to add sources for plugins in this pass over the gemfile 
280-       # since we're not actually  installing plugins here (they should already 
281-       # be  installed), just  keeping track of them so that we can verify they 
282-       # are actually  installed. This is important because otherwise sources 
280+       # since we're not installing plugins here (they should already be  
281+       # installed), only  keeping track of them so that we can verify they 
282+       # are currently  installed. This is important because otherwise sources 
283283      # unique to the plugin (like a git source) would end up in the lockfile, 
284284      # which we don't want. 
285285      normalize_options ( name ,  version ,  false ,  options ) 
286286
287287      dep  =  Dependency . new ( name ,  version ,  options ) 
288288
289-       # if there's already a dependency  with this name we try to prefer one 
289+       # if there's already a plugin  with this name we try to prefer one 
290290      if  current  =  @plugins . find  { |d | d . name  == dep . name  } 
291-         Bundler . ui . warn  "Your Gemfile lists the plugin #{ current . name } #{ current . requirement } \n "  \
292-                         "You should keep only one of them.\n "  \
293-                         "Remove any duplicate entries and specify the plugin only once." 
291+         if  current . requirement  != dep . requirement 
292+           raise  GemfileError ,  "You cannot specify the same plugin twice with different version requirements.\n "  \
293+                            "You specified: #{ current . name } #{ current . requirement } #{ dep . name } #{ dep . requirement }   \
294+                            "#{ update_prompt }  
295+         end 
296+ 
297+         if  current . source  != dep . source 
298+           raise  GemfileError ,  "You cannot specify the same plugin twice coming from different sources.\n "  \
299+                           "You specified that #{ dep . name } #{ dep . requirement }   \
300+                           "#{ current . source  || "an unspecified source" } #{ dep . source } \n " 
301+         else 
302+           Bundler . ui . warn  "Your Gemfile lists the plugin #{ current . name } #{ current . requirement } \n "  \
303+                           "You should keep only one of them.\n "  \
304+                           "Remove any duplicate entries and specify the plugin only once."  \
305+                           "While it's not a problem now, it could cause errors if you change the version of one of them later." 
306+         end 
294307      end 
295308
296309      @plugins  << dep 
0 commit comments