diff --git a/lib/tool_shed/grids/repository_grids.py b/lib/tool_shed/grids/repository_grids.py
index d0bd3fc7b9e..5828a1d3a43 100644
--- a/lib/tool_shed/grids/repository_grids.py
+++ b/lib/tool_shed/grids/repository_grids.py
@@ -843,12 +843,14 @@ class ToolDependenciesGrid( RepositoryMetadataGrid ):
# Example: "set_environment": [{"name": "JAVA_JAR_FILE", "type": "set_environment"}]
env_dicts = tds_dict[ 'set_environment' ]
num_env_dicts = len( env_dicts )
- td_str += 'environment: '
- for index, env_dict in enumerate( env_dicts ):
- td_str += '%s' % escape_html( env_dict[ 'name' ] )
- if index < num_env_dicts - 1:
- td_str += ', '
- td_str += '
'
+ if num_env_dicts > 0:
+ td_str += '' % trans.security.encode_id( repository_metadata.id )
+ td_str += 'environment: '
+ for index, env_dict in enumerate( env_dicts ):
+ td_str += '%s' % escape_html( env_dict[ 'name' ] )
+ if index < num_env_dicts - 1:
+ td_str += ', '
+ td_str += '
'
for index, key in enumerate( sorted_keys ):
if key == 'set_environment':
continue